﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
using ExcelPrinter;
using ThoughtWorks.QRCode.Codec;
using System.Drawing;
using System.Collections;
using FBWMS.DataBase;
using System.Reflection;
using System.Drawing.Printing;
using CrystalDecisions.CrystalReports.Engine;
using System.IO;
using System.Drawing.Imaging;


namespace FBWMS
{
    public class G_CommonClassBussniss
    {

        #region"COM"

        #region" Product Master Reference"

        #region "Search"

        /// <summary>
        /// Search Pruduct Information
        /// 
        /// Author:Michael
        /// Create Date:2008-11-08
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Nins_CD">Consignee Code</param>
        /// <param name="str_Shoh_CD">Proudct Code</param>
        /// <param name="str_JAN_CD">JAN</param>
        /// <param name="str_OSLoca_CD">Loaction</param>
        /// <returns></returns>
        public static DataTable G_F_COM_ProductMasterReference_GetData(string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_JAN_CD, string str_OSLoca_CD,string str_Shoh_NM)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[6];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@JAN_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_JAN_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@OSLoca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_OSLoca_CD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_NM);


                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_COM_ProductMasterReference_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_COM_ProductMasterReference_GetData Error" + err.Message, "G_F_COM_ProductMasterReference_GetData");
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        #endregion

        #endregion

        #region "Search FB_NO"

        public static DataTable G_F_COM_Search_FB_NO_GetData(string str_Search_KB, string str_Search_Mode, string str_Search_CD, string str_Data_CD,
                                                                                string str_Status, string str_Status_ST, string str_Status_ED)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {

                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[8];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_KB", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_KB);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Data_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Data_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Status);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status_ST", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Status_ST);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status_ED", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Status_ED);

                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                if (G_CommonDefine.G_Tori_CD == "HKS" && G_CommonDefine.G_HKS_Edit == "Edit")
                {
                    
                    G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_COM_Search_FB_NO_DataSelect_HKS_Edit", sqlPara, out ds);
                    sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status_ED", ParameterDirection.Input, SqlDbType.VarChar, 0, "90");
                }
                else
                    G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_COM_Search_FB_NO_DataSelect", sqlPara, out ds);
                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_USP_PC_F_COM_Search_FB_NO_DataSelect_GetData" + err.Message, "G_USP_PC_F_COM_Search_FB_NO_DataSelect_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion
        #region "Search FB_NO HKS Edit"

        public static DataTable G_F_COM_Search_FB_NO_GetData_HKS_Edit(string str_Search_KB, string str_Search_Mode, string str_Search_CD, string str_Data_CD,
                                                                                string str_Status, string str_Status_ST, string str_Status_ED)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {

                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[8];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_KB", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_KB);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Data_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Data_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Status);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status_ST", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Status_ST);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status_ED", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Status_ED);

                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_COM_Search_FB_NO_DataSelect_HKS_Edit", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_USP_PC_F_COM_Search_FB_NO_DataSelect_GetData" + err.Message, "G_USP_PC_F_COM_Search_FB_NO_DataSelect_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion
        #region"Location Select"

        #region"Search"

        /// <summary>
        /// Get Location Data
        /// 
        ///Author:Michael 
        ///Create Date:2008-11-26
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Nins_CD">Shipper Code</param>
        /// <param name="str_Loca_CD">Location</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_COM_LocationReference_GetData(string str_Tori_CD, string str_Nins_CD, string str_Loca_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Loca_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_COM_LocationReference_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_COM_LocationReference_GetData" + err.Message, "G_F_COM_LocationReference_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion

        #endregion

        #region"M_Define_XX"

        public static DataTable G_M_Define_HD_GetData()
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, out ds, "USP_PC_F_COM_M_Define_HD_GetData");

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

                return dt;
            }
            catch (Exception err)
            {

                MessageBox.Show(err.Message);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #endregion

        #region"MasterMaintenance"

        #region"Operator Master Maintenance"

        #region"Select"



        /// <summary>
        /// OutLine      : G_F_MasterMaintenance_Worker_GetData
        /// Author:Michael
        /// Create Date:2008-10-30
        /// </summary>
        /// <param name="Work_CD"></param>
        /// <returns></returns>
        public static DataTable G_F_MasterMaintenance_Worker_GetData(string Work_CD)
        {
            DataTable dt = null;
            //ds_F_MasterMaintenance_WorkerTableAdapters.USP_PC_F_MasterMaintenance_Worker_DataSelectTableAdapter ta = new ds_F_MasterMaintenance_WorkerTableAdapters.USP_PC_F_MasterMaintenance_Worker_DataSelectTableAdapter();
            //dt=ta.GetData(Work_CD);
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, Work_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_Worker_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_MasterMaintenance_Worker_GetData:" + err.Message, "G_F_MasterMaintenance_Worker_GetData");
                MessageBox.Show("G_F_MasterMaintenance_Worker_GetData:" + err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion

        #region "Insert"

        public static int G_F_MasterMaintenace_Worker_Insert(string str_Work_CD, string str_Work_NM, string str_Work_ST, string str_WKps_CD, string str_Tori_CD, string str_Group_CD)
        {

            SqlConnection connect = null;
            int result = 0;

            try
            {
                //DB愙懕
                if (!G_CommonClassDB.G_DB_Connect(out connect))
                {
                    //僄儔乕儊僢僙乕僕昞帵

                    P_MessageBox_Connection();
                    result = 99;
                    return result;

                }

                SqlCommand sqlCmd = connect.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[8];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, "1");
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Work_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_NM", ParameterDirection.Input, SqlDbType.NVarChar, 0, str_Work_NM);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_ST", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Work_ST);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PassWard", ParameterDirection.Input, SqlDbType.VarChar, 0, str_WKps_CD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Group_CD);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");
                SqlParameter[] sqloutpara;

                //僗僩傾僪幚峴
                G_CommonClassDB.G_DB_ExecStoredProc(connect, sqlCmd, "USP_PC_F_MasterMaintenance_Worker_DataUpdate", sqlPara, out sqloutpara);

                //儕僞乕儞敾掕
                result = int.Parse(sqloutpara[0].Value.ToString());
            }
            finally
            {
                if (connect != null)
                {
                    //DB奐曻
                    if (!G_CommonClassDB.G_DB_Dispose(connect))
                    {
                        //僄儔乕儊僢僙乕僕昞帵

                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        #endregion

        #region "Update"

        public static int G_F_MasterMaintenace_Worker_Update(string str_Work_CD, string str_Work_NM, string str_Work_ST, string str_WKps_CD, string str_Tori_CD, string str_Group_CD)
        {
            SqlConnection connect = null;
            int result = 0;
            try
            {
                //DB愙懕
                if (!G_CommonClassDB.G_DB_Connect(out connect))
                {
                    //僄儔乕儊僢僙乕僕昞帵

                    P_MessageBox_Connection();
                    result = 99;
                    return result;
                }

                SqlCommand sqlCmd = connect.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[8];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, "2");
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Work_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_NM", ParameterDirection.Input, SqlDbType.NVarChar, 0, str_Work_NM);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_ST", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Work_ST);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PassWard", ParameterDirection.Input, SqlDbType.VarChar, 0, str_WKps_CD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Group_CD);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");
                SqlParameter[] sqloutpara;

                //僗僩傾僪幚峴
                G_CommonClassDB.G_DB_ExecStoredProc(connect, sqlCmd, "USP_PC_F_MasterMaintenance_Worker_DataUpdate", sqlPara, out sqloutpara);

                result = int.Parse(sqloutpara[0].Value.ToString());

            }
            finally
            {
                if (connect != null)
                {
                    //DB奐曻
                    if (!G_CommonClassDB.G_DB_Dispose(connect))
                    {
                        //僄儔乕儊僢僙乕僕昞帵

                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #region"Delete"

        /// <summary>
        /// Delete Record from M_Worker
        /// 
        /// Author:Michael
        /// Create Date:2008-11-08
        /// </summary>
        /// <param name="str_Work_CD">Operator Code</param>
        /// <returns>int</returns>
        public static int G_F_MasterMaintenace_Worker_Delete(string str_Work_CD)
        {
            int result = -1;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[2];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Work_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_Worker_DataDelete", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value);

            }
            catch (Exception err)
            {


                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_MasterMaintenace_Worker_Insert" + err.Message, "G_F_MasterMaintenace_Worker_Insert");
                result = -1;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #endregion

        #region "Customer Master Maintenance"

        #region "Select"

        public static DataTable G_F_MasterMaintenance_Customer_GetData(string str_Tori_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    //僄儔乕儊僢僙乕僕昞帵
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_Customer_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception)
            {

                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    //DB奐曻
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        //僄儔乕儊僢僙乕僕昞帵
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        #endregion

        #region "Insert"

        /// <summary>
        /// Insert Data To Customer Table
        /// 
        /// Author:Michael
        /// Create Data:2008-11-07
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Cust_NM">Customer Name</param>
        /// <param name="str_Cust_ZIP">Postal Code</param>
        /// <param name="str_Cust_AD">Address </param>
        /// <param name="str_Cust_Tel">Telphone</param>
        /// <returns>int</returns>
        public static int G_F_MasterMaintenance_Customer_Insert(string str_Tori_CD, string str_Cust_NM, string str_Cust_ZIP, string str_Cust_AD, string str_Cust_Tel)
        {

            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[6];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_NM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_ZIP", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_ZIP);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_AD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_AD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_Tel", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_Tel);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutpara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_Customer_DataInsert", sqlPara, out sqloutpara);

                result = Convert.ToInt32(sqloutpara[0].Value);

            }
            catch (Exception)
            {

                result = -11;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        #endregion

        #region"Update"

        public static int G_F_MasterMaintenance_Customer_Update(string str_Tori_CD, string str_Cust_NM, string str_Cust_ZIP, string str_Cust_AD, string str_Cust_Tel)
        {

            SqlConnection connect = null;
            int result = -1;
            try
            {

                //DB Open Connection
                if (!G_CommonClassDB.G_DB_Connect(out connect))
                {
                    P_MessageBox_Connection();
                    return result;
                }

                SqlCommand sqlCmd = connect.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[6];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_NM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_ZIP", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_ZIP);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_AD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_AD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_Tel", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_Tel);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqlOutPara;

                //ストアド実行
                G_CommonClassDB.G_DB_ExecStoredProc(connect, sqlCmd, "USP_PC_F_MasterMaintenance_Customer_DataUpdate", sqlPara, out sqlOutPara);

                result = Convert.ToInt32(sqlOutPara[0].Value);
            }
            finally
            {
                if (connect != null)
                {
                    //DB Dispose Connection
                    if (!G_CommonClassDB.G_DB_Dispose(connect))
                    {
                        //P_MessageBox_Disonnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #region"Delete"

        public static int G_F_MasterMaintenance_Customer_Delete(string str_Tori_CD)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[2];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.VarChar, 0, "0");

                SqlParameter[] sqloutpara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_Customer_DataDelete", sqlPara, out sqloutpara);

                result = Convert.ToInt32(sqloutpara[0].Value);


            }
            catch (Exception)
            {

                result = -5;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }


            return result;
        }

        #endregion

        #endregion

        #region "System Info Control Master"

        #region"Select"

        public static DataTable G_F_MasterMaintenance_Sys_Manager_GetData(string str_Tori_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    //僄儔乕儊僢僙乕僕昞帵
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_Sys_Manager_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception)
            {

                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    //DB奐曻
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        //僄儔乕儊僢僙乕僕昞帵
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        #endregion

        #region"Insert"

        /// <summary>
        /// Insert Record to M_Sys_Manager
        /// 
        /// Author:Michael
        /// Create Date:2008-11-08
        /// </summary>
        /// <param name="sysManager">M_Sys_Manager Table Data Entry Class</param>
        /// <returns></returns>
        public static int G_F_MasterMaintenance_Sys_Manager_Insert(G_CommonClassDBEntry.SysManagerMaster sysManager)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[14];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sysManager.str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@TrSt_NM", ParameterDirection.Input, SqlDbType.NVarChar, 0, sysManager.str_TrSt_NM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mortgage_Temporary_PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, sysManager.str_Mortgage_Temporary_PC_NM);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Printer_PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, sysManager.str_Printer_PC_NM);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Kari_FG", ParameterDirection.Input, SqlDbType.Bit, 0, sysManager.str_Kari_FG);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Kari_PCNM", ParameterDirection.Input, SqlDbType.VarChar, 0, sysManager.str_Kari_PCNM);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@UnsoDecide_FG", ParameterDirection.Input, SqlDbType.Bit, 0, sysManager.str_UnsoDecide_FG);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@UnsoDecide_PC", ParameterDirection.Input, SqlDbType.VarChar, 0, sysManager.str_UnsoDecide_PC);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@JH_Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sysManager.str_JH_Loca_CD);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@DS_Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sysManager.str_DS_Loca_CD);
                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@MM_Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sysManager.str_MM_Loca_CD);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Emg_Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sysManager.str_Emg_Loca_CD);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Zatsu_Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sysManager.str_Zatsu_Loca_CD);
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_Sys_Manager_DataInsert", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value);


            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_MasterMaintenance_Sys_Manager_Insert  Error" + err.Message, "G_F_MasterMaintenance_Sys_Manager_Insert");
                result = -11;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        #endregion

        #region "Update"

        public static int G_F_MasterMaintenance_Sys_Manager_Update(string str_Tori_CD, string str_TrSt_NM, string str_Mortgage_Temporary_PC_NM, string str_Printer_PC_NM,
                                                                  string str_Kari_FG, string str_Kari_PCNM, string str_UnsoDecide_FG, string str_UnsoDecide_PC, string str_JH_Loca_CD,
                                                                  string str_DS_Loca_CD, string str_MM_Loca_CD, string str_Emg_Loca_CD, string str_Zatsu_Loca_CD)
        {

            int result = -1;
            SqlConnection connect = null;

            try
            {
                //DB愙懕
                if (!G_CommonClassDB.G_DB_Connect(out connect))
                {
                    P_MessageBox_Connection();
                    return result;
                }

                SqlCommand sqlCmd = connect.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[15];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@TrSt_NM", ParameterDirection.Input, SqlDbType.NVarChar, 0, str_TrSt_NM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mortgage_Temporary_PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Mortgage_Temporary_PC_NM);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Printer_PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Printer_PC_NM);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Kari_FG", ParameterDirection.Input, SqlDbType.Bit, 0, str_Kari_FG);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Kari_PCNM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Kari_PCNM);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@UnsoDecide_FG", ParameterDirection.Input, SqlDbType.Bit, 0, str_UnsoDecide_FG);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@UnsoDecide_PC", ParameterDirection.Input, SqlDbType.VarChar, 0, str_UnsoDecide_PC);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@JH_Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_JH_Loca_CD);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@DS_Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_DS_Loca_CD);
                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@MM_Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_MM_Loca_CD);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Emg_Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Emg_Loca_CD);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Zatsu_Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Zatsu_Loca_CD);
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Upd_DT", ParameterDirection.Input, SqlDbType.SmallDateTime, 0, DateTime.Now.ToString());
                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqlOutPara;

                //僗僩傾僪幚峴
                G_CommonClassDB.G_DB_ExecStoredProc(connect, sqlCmd, "USP_PC_F_MasterMaintenance_Sys_Manager_DataUpdate", sqlPara, out sqlOutPara);

                result = Convert.ToInt32(sqlOutPara[0].Value);

            }
            finally
            {
                if (connect != null)
                {
                    //DB夝曻
                    if (!G_CommonClassDB.G_DB_Dispose(connect))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #region"Delete"

        /// <summary>
        /// Delete Record from M_Sys_Manager table
        /// 
        /// Author:Michael
        /// Create Date:2008-11-08
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <returns>int</returns>
        public static int G_F_MasterMaintenance_Sys_Manager_Delete(string str_Tori_CD)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[2];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_Sys_Manager_DataDelete", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value);

            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_MasterMaintenance_Sys_Manager_Delete Error" + err.Message, "G_F_MasterMaintenance_Sys_Manager_Delete");
                result = -11;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        #endregion

        #endregion

        #region"Products Warning"

        #region"Select"

        public static DataTable G_F_MasterMaintenance_ProductWarning_GetData(string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_Jyot_KB)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[4];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyot_KB);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_ProductWarning_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception)
            {
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    //DB奐曻
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        //僄儔乕儊僢僙乕僕昞帵
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        #endregion

        #region"Insert"

        public static int G_F_MasterMaintenance_ProductWarning_Insert(string str_sTori_CD, string str_sNins_CD, string str_sShoh_CD, string str_sJyot_KB, string str_WarningInfo)
        {

            return G_F_MasterMaintenance_ProductWarning_UpdateBase(str_sTori_CD, str_sNins_CD, str_sShoh_CD, str_sJyot_KB, str_WarningInfo, "1");
        }

        #endregion

        #region"Update"

        public static int G_F_MasterMaintenance_ProductWarning_Update(string str_sTori_CD, string str_sNins_CD, string str_sShoh_CD, string str_sJyot_KB, string str_WarningInfo)
        {

            return G_F_MasterMaintenance_ProductWarning_UpdateBase(str_sTori_CD, str_sNins_CD, str_sShoh_CD, str_sJyot_KB, str_WarningInfo, "2");
        }

        #endregion

        #region"Delete"

        public static int G_F_MasterMaintenance_ProductWarning_Delete(string str_sTori_CD, string str_sNins_CD, string str_sShoh_CD, string str_sJyot_KB, string str_WarningInfo)
        {

            return G_F_MasterMaintenance_ProductWarning_UpdateBase(str_sTori_CD, str_sNins_CD, str_sShoh_CD, str_sJyot_KB, str_WarningInfo, "3");
        }

        #endregion

        #region "Update data base"

        private static int G_F_MasterMaintenance_ProductWarning_UpdateBase(string str_sTori_CD, string str_sNins_CD, string str_sShoh_CD, string str_sJyot_KB, string str_WarningInfo, string str_Mode)
        {
            int result = 99;

            SqlConnection connect = null;

            try
            {
                //DB接続
                if (!G_CommonClassDB.G_DB_Connect(out connect))
                {
                    //エラーメッセージ表示
                    P_MessageBox_Connection();
                    return result;
                }

                SqlCommand sqlCmd = connect.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[7];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_sTori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_sNins_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_sShoh_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_sJyot_KB);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Warning_TXT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_WarningInfo);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");
                SqlParameter[] sqloutpara;

                //ストアド実行
                G_CommonClassDB.G_DB_ExecStoredProc(connect, sqlCmd, "USP_PC_F_MasterMaintenance_ProductWarning_DataUpdate", sqlPara, out sqloutpara);

                result = Convert.ToInt32(sqloutpara[0].Value);

            }
            finally
            {
                if (connect != null)
                {
                    //DB開放
                    if (!G_CommonClassDB.G_DB_Dispose(connect))
                    {
                        //エラーメッセージ表示
                        P_MessageBox_Disconnection();
                    }
                }

            }
            return result;
        }

        #endregion

        #endregion

        #region "Delivery Method Master"

        #region"Select"

        public static DataTable G_F_MasterMaintenance_Foward_GetData(string str_Tori_CD, string str_Unso_CD)
        {

            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[2];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Unso_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_Foward_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception)
            {
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion

        #region "Insert"

        //public static int G_F_MasterMaintenance_Foward_Insert(string str_Tori_CD, string str_unso_CD, string str_Fwst_NM,
        //                                                   string str_Fwfl_NM, string str_Cur_Fw_NO, string str_St_Fw_NO, string str_End_Fw_NO,
        //                                                   string str_Unso_KB, string str_ChkD_NO, string str_FwNo_Length, string str_Okri_KB,
        //                                                   string str_Nifuda_NM, string str_ZipChk_FG)
        //{
        //    string str_Mode = "0";
        //    return P_F_MasterMaintenance_Foward_UpdateData(str_Mode, str_Tori_CD, str_unso_CD, str_Fwst_NM,
        //                                                   str_Fwfl_NM, str_Cur_Fw_NO, str_St_Fw_NO, str_End_Fw_NO,
        //                                                   str_Unso_KB, str_ChkD_NO, str_FwNo_Length, str_Okri_KB,
        //                                                   tr_Nifuda_NM, str_ZipChk_FG);
        //}

        #endregion

        #region "Update"

        //public static int G_F_MasterMaintenance_Foward_Update(string str_Tori_CD, string str_unso_CD, string str_Fwst_NM,
        //                                                           string str_Fwfl_NM, string str_Cur_Fw_NO, string str_St_Fw_NO, string str_End_Fw_NO,
        //                                                           string str_Unso_KB, string str_ChkD_NO, string str_FwNo_Length, string str_Okri_KB,
        //                                                           string str_Nifuda_NM, string str_ZipChk_FG)
        //{
        //    string str_Mode="1";
        //    return P_F_MasterMaintenance_Foward_UpdateData(str_Mode, str_Tori_CD, str_unso_CD, str_Fwst_NM,
        //                                                   str_Fwfl_NM, str_Cur_Fw_NO, str_St_Fw_NO, str_End_Fw_NO, 
        //                                                   str_Unso_KB, str_ChkD_NO, str_FwNo_Length, str_Okri_KB,
        //                                                   tr_Nifuda_NM, str_ZipChk_FG);                                               
        //}

        #endregion

        #region"Update data base"


        public static int G_F_MasterMaintenance_Foward_UpdateData(string str_Mode, string str_Tori_CD, string str_unso_CD, string str_Fwst_NM,
                                                                   string str_Fwfl_NM, string str_Cur_Fw_NO, string str_St_Fw_NO, string str_End_Fw_NO,
                                                                   string str_Unso_KB, string str_ChkD_NO, string str_FwNo_Length, string str_Okri_KB,
                                                                   string str_Nifuda_NM, string str_ZipChk_FG)
        {
            int result = -1;


            SqlConnection connect = null;

            try
            {
                //DB接続
                if (!G_CommonClassDB.G_DB_Connect(out connect))
                {
                    P_MessageBox_Connection();
                    return result;
                }

                SqlCommand sqlCmd = connect.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[17];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_unso_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Fwst_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Fwst_NM);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Fwfl_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Fwfl_NM);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cur_Fw_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cur_Fw_NO);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@St_Fw_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_St_Fw_NO);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@End_Fw_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_End_Fw_NO);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Unso_KB);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ChkD_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_ChkD_NO);
                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Reg_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, DateTime.Now.ToString());
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Upd_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, DateTime.Now.ToString());
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FwNo_Length", ParameterDirection.Input, SqlDbType.VarChar, 0, str_FwNo_Length);

                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Okri_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Okri_KB);
                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nifuda_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nifuda_NM);
                sqlPara[15] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ZipChk_FG", ParameterDirection.Input, SqlDbType.VarChar, 0, str_ZipChk_FG);
                sqlPara[16] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqlOutPara;

                //ストアド実行
                G_CommonClassDB.G_DB_ExecStoredProc(connect, sqlCmd, "USP_PC_F_MasterMaintenance_Foward_DataUpdate", sqlPara, out sqlOutPara);

                result = Convert.ToInt32(sqlOutPara[0].Value);
            }
            finally
            {
                if (connect != null)
                {
                    //DB解放
                    if (!G_CommonClassDB.G_DB_Dispose(connect))
                    {
                        P_MessageBox_Disconnection();
                    }
                }

            }
            return result;
        }

        #endregion

        #region"Delete"

        public static int G_F_MasterMaintenance_Foward_Delete(string str_Tori_CD, string str_unso_CD)
        {
            int result = -1;

            SqlConnection connect = null;

            try
            {
                //DB接続
                if (!G_CommonClassDB.G_DB_Connect(out connect))
                {

                    P_MessageBox_Connection();
                    return result;
                }

                SqlCommand sqlCmd = connect.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_unso_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqlOutPara;

                //ストアド実行
                G_CommonClassDB.G_DB_ExecStoredProc(connect, sqlCmd, "USP_PC_F_MasterMaintenance_Foward_DataDelete", sqlPara, out sqlOutPara);

                result = Convert.ToInt32(sqlOutPara[0].Value);


            }
            catch (Exception ex)
            {
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_MasterMaintenance_Foward_Delete Error" + ex.Message, "G_F_MasterMaintenance_Foward_Delete");
            }
            finally
            {
                if (connect != null)
                {
                    //DB解放
                    if (!G_CommonClassDB.G_DB_Dispose(connect))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        #endregion

        #endregion

        #region "Products Master"

        #region "select"

        /// <summary>
        /// Select Product Data
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Nins_CD">Consignee Code</param>
        /// <param name="str_Shoh_CD">Product Code</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_MasterMaintenance_Product_GetData(string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {

                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[3];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_Product_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception)
            {

                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }


        #endregion

        #region"Insert"

        #endregion

        #region "Update"





        #endregion

        #region"Delete"
        #endregion

        #region "Update data base"

        public static int G_F_MasterMaintenance_Product_UpdateData(G_CommonClassDBEntry.ProductMaster product)
        {

            int result = -11;
            SqlConnection connect = null;

            try
            {
                //DB接続
                if (!G_CommonClassDB.G_DB_Connect(out connect))
                {
                    //エラーメッセージ表示
                    P_MessageBox_Connection();
                    return result;
                }

                SqlCommand sqlCmd = connect.CreateCommand();

                //画面上の値を、Sqlparameterにセット

                SqlParameter[] sqlPara = new SqlParameter[25];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, product.str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, product.str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, product.str_Nins_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, product.str_Shoh_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, product.str_Shoh_NM);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@JAN_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, product.str_JAN_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_H", ParameterDirection.Input, SqlDbType.Float, 0, product.str_Shoh_H);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_W", ParameterDirection.Input, SqlDbType.Float, 0, product.str_Shoh_W);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_L", ParameterDirection.Input, SqlDbType.Float, 0, product.str_Shoh_L);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Iri_QT", ParameterDirection.Input, SqlDbType.Int, 0, product.str_Iri_QT);

                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Set_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, product.str_Set_KB);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Set_KB_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, product.str_Set_KB_NM);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tani_NM", ParameterDirection.Input, SqlDbType.NVarChar, 0, product.str_Tani_NM);
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tani_Para_NM", ParameterDirection.Input, SqlDbType.NVarChar, 0, product.str_Tani_Para_NM);
                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Hatu_QT", ParameterDirection.Input, SqlDbType.Int, 0, product.str_Hatu_QT);

                sqlPara[15] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ShIF_TXT", ParameterDirection.Input, SqlDbType.VarChar, 0, product.str_ShIF_TXT);
                sqlPara[16] = G_CommonClassDB.G_DB_SetSQLDBParameter("@OsZone", ParameterDirection.Input, SqlDbType.VarChar, 0, product.str_OsZone);
                sqlPara[17] = G_CommonClassDB.G_DB_SetSQLDBParameter("@OSLoca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, product.str_OSLoca_CD);
                sqlPara[18] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sub01", ParameterDirection.Input, SqlDbType.Int, 0, product.str_Sub01);
                sqlPara[19] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sub02", ParameterDirection.Input, SqlDbType.Int, 0, product.str_Sub02);

                sqlPara[20] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_GW", ParameterDirection.Input, SqlDbType.Decimal, 0, product.str_Shoh_GW);
                //Modify By Will Date:2009-08-03
                sqlPara[21] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Hinmei_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, product.str_Hinmei_NM);
                sqlPara[22] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, product.str_Group_NM);
                //Modify By Will Date:2009-08-07
                sqlPara[23] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jist_WT", ParameterDirection.Input, SqlDbType.Decimal, 0, product.str_Jist_WT);
                sqlPara[24] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");
                SqlParameter[] sqloutpara;



                //ストアド実行
                G_CommonClassDB.G_DB_ExecStoredProc(connect, sqlCmd, "USP_PC_F_MasterMaintenance_Product_DataUpdate", sqlPara, out sqloutpara);

                result = int.Parse(sqloutpara[0].Value.ToString());
            }
            finally
            {
                if (connect != null)
                {
                    //DB開放
                    if (!G_CommonClassDB.G_DB_Dispose(connect))
                    {
                        //エラーメッセージ表示
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion
        #endregion

        #region "Serial Selection"

        #region "select"

        public static DataTable G_F_COM_SerialMasterReference_GetData(string str_Tori_CD, string str_Nins_CD, string str_Serial_CD, string str_Shoh_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[4];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Serial_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Serial_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_COM_SerialMasterReference_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }


        #endregion

        #endregion

        #region "Serial Warning"

        #region"Select"

        public static DataTable G_F_MasterMaintenance_SerialWarning_GetData(string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_Serial_CD, string str_Serial_CD_E)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[5];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD",ParameterDirection.Input,SqlDbType.VarChar,0,str_Shoh_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Serial_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Serial_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Serial_CD_E", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Serial_CD_E);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_SerialWarning_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception)
            {

                dt = null;
                return dt;
            }
            return dt;
        }

        #endregion

        #region"Update Data Base"

        /// <summary>
        /// Insert Modify Delete Data
        /// </summary>
        /// <param name="str_Mode"></param>
        /// <param name="str_Tori_CD"></param>
        /// <param name="str_Nins_CD"></param>
        /// <param name="str_Serial_CD"></param>
        /// <param name="str_Jyot_KB"></param>
        /// <param name="str_Warning_TXT"></param>
        /// <returns></returns>
        public static int G_F_MasterMaintenance_SerialWarning_UpdateData(string str_Mode, string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD,string str_Serial_CD,
                                                                                string str_Warning_TXT)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[7];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Serial_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Serial_CD);

             
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Warning_TXT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Warning_TXT);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutpara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_SerialWarning_DataUpdate", sqlPara, out sqloutpara);

                result = Convert.ToInt32(sqloutpara[0].Value);

            }
            catch (Exception)
            {

                result = -11;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        #endregion

        #endregion

        #region "Batch Serail Warning"

        public static DataTable G_F_MasterMaintenance_SerialWarningNew_GetData(string str_Mode, string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_Serial_CD_S, string str_Serial_CD_E)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[7];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Serial_CD_S", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Serial_CD_S);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Serial_CD_E", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Serial_CD_E);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_SerialWarningNew_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        public static int G_F_MasterMaintenance_SerialWarningNew_Sub_DataUpdate(string str_Mode, string str_ID, string str_Flag)
        {

            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
             

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[5];

                SqlParameter[] sqlOutPara;

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Id", ParameterDirection.Input, SqlDbType.Int, 0, str_ID);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Flag", ParameterDirection.Input, SqlDbType.Int, 0, str_Flag);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");
                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_SerialWarningNew_Sub_DataUpdate", sqlPara, out sqlOutPara);

                if ((sqlOutPara != null) && (sqlOutPara.Length > 0))
                {
                    if (sqlOutPara[0].Value.ToString() == "0")
                    {
                        result = 0;
                    }
                }
                return result;
            }
            catch (Exception err)
            {

                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static int G_F_MasterMaintenance_SerialWarningNew_UpdateData(string str_Mode, string str_Tori_CD, string str_Nins_CD,string str_Shoh_CD,
                                                                          string str_Warning_TXT)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[8];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Warning_TXT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Warning_TXT);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);

                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutpara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_SerialWarningNew_DataUpdate", sqlPara, out sqloutpara);

                result = Convert.ToInt32(sqloutpara[0].Value);

            }
            catch (Exception)
            {

                result = -11;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }


        #endregion

        #region "PLot Warning Information"


        public static DataTable G_F_MasterMaintenance_PLotWarningNew_GetData(string str_Mode, string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_Serial_CD_S, string str_Serial_CD_E)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[7];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Lot_CD_S", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Serial_CD_S);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Lot_CD_E", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Serial_CD_E);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_LotWarningNew_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }


        public static int G_F_MasterMaintenance_PLotWarningNew_Sub_DataUpdate(string str_Mode, string str_ID, string str_Flag)
        {

            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }


                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[5];

                SqlParameter[] sqlOutPara;

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Id", ParameterDirection.Input, SqlDbType.Int, 0, str_ID);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Flag", ParameterDirection.Input, SqlDbType.Int, 0, str_Flag);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");
                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_LotWarningNew_Sub_DataUpdate", sqlPara, out sqlOutPara);

                if ((sqlOutPara != null) && (sqlOutPara.Length > 0))
                {
                    if (sqlOutPara[0].Value.ToString() == "0")
                    {
                        result = 0;
                    }
                }
                return result;
            }
            catch (Exception err)
            {

                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }


        public static int G_F_MasterMaintenance_PLotWarningNew_UpdateData(string str_Mode, string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD,
                                                                  string str_Warning_TXT)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[8];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Warning_TXT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Warning_TXT);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);

                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutpara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_LotWarningNew_DataUpdate", sqlPara, out sqloutpara);

                result = Convert.ToInt32(sqloutpara[0].Value);

            }
            catch (Exception)
            {

                result = -11;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }



        #endregion


        #region "Customer Group Master"

        #region "Search"

        /// <summary>
        /// Get Customer Group Master Data source 
        /// 
        /// Author :Michael
        /// Create :2008-11-04
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Group_CD">Customer Group Code</param>
        /// <param name="str_Sec_CD">Section Code</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_MasterMaintenance_CustomerGroup_GetData(string str_Tori_CD, string str_Group_CD, string str_Sec_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Group_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sec_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Sec_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_CustGroup_Screen_DataSelect", sqlPara, out ds);

                if ((ds != null) || (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception)
            {

                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        public static DataTable G_F_MasterMaintenance_CustomerGroup_GetData_HD(string str_Tori_CD, string str_Group_CD, string str_Sec_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Group_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sec_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Sec_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_CustGroup_Screen_DataSelect_HD", sqlPara, out ds);

                if ((ds != null) || (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception)
            {

                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }


        public static DataTable G_F_MasterMaintenance_CustomerGroup_GetData_BD(string str_Id)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Para_ID", ParameterDirection.Input, SqlDbType.Int, 0, str_Id);


                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_CustGroup_Screen_DataSelect_BD", sqlPara, out ds);

                if ((ds != null) || (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception)
            {

                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }
        #endregion

        #region"Update Data Base"

        public static int G_F_MasterMaintenance_CustomerGroup_UpdateData(string str_Mode, string str_ID, string str_Tori_CD, string str_Group_CD, string str_Sec_CD)
        {
            int result = -11;

            SqlConnection sqlConnction = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnction))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                //DataSet ds = null;

                SqlCommand sqlCommand = sqlConnction.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[6];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ID", ParameterDirection.Input, SqlDbType.Int, 0, str_ID);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Group_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sec_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Sec_CD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutpara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnction, sqlCommand, "USP_PC_F_MasterMaintenance_CustGroup_Screen_DataUpdate", sqlPara, out sqloutpara);

                result = Convert.ToInt32(sqloutpara[0].Value);

            }
            catch (Exception)
            {

                result = -11;
                return result;
            }
            finally
            {
                if (sqlConnction != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnction))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        public static int G_F_MasterMaintenance_CustomerGroup_Sub_UpdateData(G_CommonClassDBEntry.CustomerGroupBD groupBD)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                //DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[11];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, groupBD.str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ID", ParameterDirection.Input, SqlDbType.Int, 0, groupBD.str_Id);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, groupBD.str_Tori_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, groupBD.str_Group_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sec_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, groupBD.str_Sec_CD);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SEQ_NO", ParameterDirection.Input, SqlDbType.Int, 0, groupBD.str_SEQ_NO);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cur_SC", ParameterDirection.Input, SqlDbType.VarChar, 0, groupBD.str_Cur_SC);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Next_SC", ParameterDirection.Input, SqlDbType.VarChar, 0, groupBD.str_Next_SC);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Class_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, groupBD.str_Class_CD);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@CDT_Txt", ParameterDirection.Input, SqlDbType.VarChar, 0, groupBD.str_CDT_Txt);

                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutpara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_CustGroup_Screen_sub_DataUpdate", sqlPara, out sqloutpara);

                result = Convert.ToInt32(sqloutpara[0].Value);

            }
            catch (Exception)
            {

                result = -11;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        #endregion

        #region "Delete"

        public static int G_F_MasterMaintenance_CustomerGroup_DeleteData(string str_ID)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[2];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Id", ParameterDirection.Input, SqlDbType.Int, 0, str_ID);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutpara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_CustGroup_Screen_DataDelete", sqlPara, out sqloutpara);

                result = Convert.ToInt32(sqloutpara[0].Value);


            }
            catch (Exception)
            {

                result = -11;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        public static int G_F_MasterMaintenance_CustomerGroup_Sub_DeleteData(string str_ID)
        {

            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[2];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Id", ParameterDirection.Input, SqlDbType.Int, 0, str_ID);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutpara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_MasterMaintenance_CustGroup_Screen_Sub_DataDelete", sqlPara, out sqloutpara);

                result = Convert.ToInt32(sqloutpara[0].Value);


            }
            catch (Exception)
            {

                result = -11;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        #endregion

        #endregion

        #endregion

        #region "Issuing"

        #region"Delivery Schedule Entry"

        #region"Search"

        /// <summary>
        /// Get DataGrid Data
        /// 
        /// 
        /// author:michael
        /// create date:2008-11-08
        /// </summary>
        /// <param name="str_PC_NM">PC Name</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Syk_EditSykData_GetData_Sub(string str_PC_NM)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EditSykData_SUB_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EditSykData_GetData_Detail" + err.Message, "G_F_Syk_EditSykData_GetData_Detail");
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        /// <summary>
        /// Search Delivery Schedule Entry Data
        /// 
        /// 
        /// Author:Michael
        /// Create Date:2008-11-08
        /// </summary>
        /// <param name="str_FB_NO">FB_NO</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Syk_EditSykData_GetData(string str_FB_NO)
        {

            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_FB_NO);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EditSykData_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EditSykData_GetData" + err.Message, "G_F_Syk_EditSykData_GetData");
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        #endregion

        #region "Update"

        public static int G_F_Syk_EditSykData_Sub_Update_Master(string str_Mode, string str_BD_ID, string str_Uria_No, string str_UriaPos_No,
                                                         string str_Meis_KB, string str_Shoh_CD, string str_Shoh_NM, string str_JAN_CD,
                                                         string str_Yote_QT, string str_Price, string str_CPO_POS, string str_ATI_QT, string str_Jyot_KB, string str_Souk_CD, string str_PC_NM)
        {
            int result = -11;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[16];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@BD_ID", ParameterDirection.Input, SqlDbType.Int, 0, str_BD_ID);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Uria_No", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Uria_No);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@UriaPos_No", ParameterDirection.Input, SqlDbType.Int, 0, str_UriaPos_No);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Meis_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Meis_KB);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_NM);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@JAN_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_JAN_CD);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Yote_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Yote_QT);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Price", ParameterDirection.Input, SqlDbType.Int, 0, str_Price);

                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@CPO_POS", ParameterDirection.Input, SqlDbType.VarChar, 0, str_CPO_POS);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ATI_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_ATI_QT);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyot_KB);
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Souk_CD);
                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[15] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");
                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EditSykData_SUB_DataUpdate", sqlPara, out sqloutPara);

                result = int.Parse(sqloutPara[0].Value.ToString());
            }
            catch (Exception err)
            {


                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EditSykData_Sub_Update" + err.Message, "G_F_Syk_EditSykData_Sub_Update");
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }


            return result;
        }

        /// <summary>
        /// Delivery Data Entry
        /// 
        /// Author:Michael
        /// Create Date:2008-11-29
        /// </summary>
        /// <param name="sykData"></param>
        /// <returns></returns>
        public static int G_F_Syk_EditSykData_Update_Master(G_CommonClassDBEntry.SykDataMaster sykData)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[51];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, sykData.str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, sykData.str_FB_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Tori_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Attribute_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Attribute_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nouk_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Nouk_DT);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Unso_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Denp_Biko", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Denp_Biko);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Uria_No", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Uria_No);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jytu_DT", ParameterDirection.Input, SqlDbType.DateTime, 0, sykData.str_Jytu_DT);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_CD);

                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_Zip_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_Zip_NO);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_AD_01", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_AD_01);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_AD_02", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_AD_02);
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_AD_03", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_AD_03);
                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_NM_01", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_NM_01);

                sqlPara[15] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_NM_02", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_NM_02);
                sqlPara[16] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_Tel_No", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_Tel_No);
                sqlPara[17] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_CD);
                sqlPara[18] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_Zip_No", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_Zip_No);
                sqlPara[19] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_AD_01", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_AD_01);

                sqlPara[20] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_AD_02", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_AD_02);
                sqlPara[21] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_AD_03", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_AD_03);
                sqlPara[22] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_NM_01", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_NM_01);
                sqlPara[23] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_NM_02", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_NM_02);
                sqlPara[24] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_Tel_No", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_Tel_No);

                sqlPara[25] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Konp_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Konp_KB);
                sqlPara[26] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Instructions", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Instructions);
                sqlPara[27] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Time_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Time_CD);
                sqlPara[28] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Inji_QT", ParameterDirection.Input, SqlDbType.Int, 0, sykData.str_Inji_QT);
                sqlPara[29] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyht_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Jyht_NO);

                sqlPara[30] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tant_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Tant_NM);
                sqlPara[31] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ktyu_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Ktyu_NO);
                sqlPara[32] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Hrai_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Nsai_KB);
                sqlPara[33] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nsai_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Nsai_KB);
                sqlPara[34] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Edom_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Edom_KB);

                sqlPara[35] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sden_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Sden_KB);
                sqlPara[36] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Siji_DT", ParameterDirection.Input, SqlDbType.DateTime, 0, sykData.str_Siji_DT);
                sqlPara[37] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Uria_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Uria_DT);
                sqlPara[38] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Bik_02_TXT", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Bik_02_TXT);
                sqlPara[39] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Bik_03_TXT", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Bik_03_TXT);

                sqlPara[40] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_PC_NM);
                //////////////////////////// 2008.04.30 Araki Add Start ////////////////////////////
                sqlPara[41] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Work_CD);
                //////////////////////////// 2008.04.30 Araki Add End //////////////////////////////

                sqlPara[42] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Souk_CD);
                sqlPara[43] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Souk_NM);
                sqlPara[44] = G_CommonClassDB.G_DB_SetSQLDBParameter("@DO_No", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_DO_No);
                sqlPara[45] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PIC_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_PIC_CD);
                sqlPara[46] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PIC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_PIC_NM);
                sqlPara[47] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tant_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Tant_CD);

                sqlPara[48] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Group_NM);
                sqlPara[49] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_SECTION_CODE);


                sqlPara[50] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EditSykData_DataUpdate", sqlPara, out sqloutPara);

                result = int.Parse(sqloutPara[0].Value.ToString());
            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EditSykData_Update_Master" + err.Message, "G_F_Syk_EditSykData_Update_Master");
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #region"Delete"

        /// <summary>
        /// Delete Delivery Data Entry
        /// 
        /// Author:Michae
        /// Create Date:2008-11-29
        /// </summary>
        /// <param name="str_Mode"></param>
        /// <param name="str_FB_NO"></param>
        /// <param name="str_PC_NM"></param>
        /// <param name="str_Work_CD"></param>
        /// <returns></returns>
        public static int G_F_Syk_EditSykData_Delete(string str_Mode, string str_FB_NO, string str_PC_NM, string str_Work_CD)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[5];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_FB_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                //////////////////////////// 2008.04.30 Araki Add Start ////////////////////////////
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Work_CD);
                //////////////////////////// 2008.04.30 Araki Add End //////////////////////////////
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");


                SqlParameter[] sqlOutPara;

                //ストアド実行
                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EditSykData_DataDelete", sqlPara, out sqlOutPara);

                result = int.Parse(sqlOutPara[0].Value.ToString());
            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EditSykData_Delete" + err.Message, "G_F_Syk_EditSykData_Delete");
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        #endregion

        #region "Insert"

        /// <summary>
        /// Search Insert Data
        /// 
        /// Author:Michael
        /// Create Data:2008-11-29
        /// </summary>
        /// <param name="str_FB_NO">FB_NO</param>
        /// <param name="str_PC_NM">PC Name</param>
        /// <returns>Int</returns>
        public static int G_F_Syk_EditSykData_Insert(string str_FB_NO, string str_PC_NM)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EditSykData_DataInsert", sqlPara, out sqloutPara);

                result = int.Parse(sqloutPara[0].Value.ToString());
            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EditSykData_Insert" + err.Message, "G_F_Syk_EditSykData_Insert");
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #endregion

        #region "Delivery Method & Consolidation Entry"

        #region"Search"

        /// <summary>
        /// Search Data :The first step Delete data 
        /// 
        /// 
        /// Author:Michael
        /// Create Date:2008-11-10
        /// </summary>
        /// <param name="str_Mode">Mode</param>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <returns>Boolean</returns>
        public static bool G_F_Syk_EditUnsoDecide_Delete(string str_Mode, string str_Tori_CD)
        {

            SqlConnection connect = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out connect))
                {

                    P_MessageBox_Connection();
                    return false;
                }

                SqlCommand sqlCmd = connect.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[5];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 25, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 25, G_CommonDefine.G_PCNM.ToString());
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 25, G_CommonDefine.G_str_Customer_SEC_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@RET", ParameterDirection.Output, SqlDbType.Int, 0, "0");
                SqlParameter[] sqloutpara;

                G_CommonClassDB.G_DB_ExecStoredProc(connect, sqlCmd, "USP_PC_F_Syk_EditUnsoDecide_DataDelete", sqlPara, out sqloutpara);

            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "P_DEL_F_Syk_EditUnsoDecide Error" + err.Message, "P_DEL_F_Syk_EditUnsoDecide");

                MessageBox.Show("P_DEL_F_Syk_EditUnsoDecide Error" + err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return false;
            }
            finally
            {
                if (connect != null)
                {

                    if (!G_CommonClassDB.G_DB_Dispose(connect))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return true;
        }

        /// <summary>
        /// Search Data: The second step Insert data
        /// 
        /// 
        /// Author:Michale
        /// Create Date:2008-11-10
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Datetype">Data Condition</param>
        /// <param name="str_Target_DT">Data Value</param>
        /// <param name="str_Attribute_CD">Attribute Code</param>
        /// <param name="str_Tokki_KB">Remark Mode</param>
        /// <param name="str_Unso_CD">Delivery Method</param>
        /// <param name="str_Search_Mode">Search Condition</param>
        /// <param name="str_Search_CD">Condition Value</param>
        /// <returns>Int</returns>
        public static int G_F_Syk_EditUnsoDecide_Insert(string str_Tori_CD, string str_Datetype, string str_Target_DT, string str_Attribute_CD, string str_Tokki_KB,
                                                         string str_Unso_CD, string str_Search_Mode, string str_Search_CD, string str_Souk_CD, string str_Section_Code)
        {
            int result = -11;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[12];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 25, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Datetype", ParameterDirection.Input, SqlDbType.Int, 0, str_Datetype);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Target_DT", ParameterDirection.Input, SqlDbType.VarChar, 10, str_Target_DT);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Attribute_CD", ParameterDirection.Input, SqlDbType.VarChar, 2, str_Attribute_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tokki_KB", ParameterDirection.Input, SqlDbType.VarChar, 2, str_Tokki_KB);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 60, str_Unso_CD);

                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 20, str_Search_CD);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 20, str_Souk_CD);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 20, str_Section_Code);



                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 25, G_CommonDefine.G_PCNM.ToString());
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@RET", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EditUnsoDecide_DataInsert", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value);

            }
            catch (Exception err)
            {
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EditUnsoDecide_Insert Error" + err.Message, "G_F_Syk_EditUnsoDecide_Insert");
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }


        /// <summary>
        /// Search Data: The Three step Inqure
        /// </summary>
        /// <param name="str_PC_NM">PC Address</param>
        /// <param name="str_OrderBy">Order by Column</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Syk_EditUnsoDecide_GetData(string str_PC_NM, string str_OrderBy)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();

                    return dt;
                }

                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[2];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("OrderBy", ParameterDirection.Input, SqlDbType.Int, 0, str_OrderBy);



                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EditUnsoDecide_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EditUnsoDecide_GetData" + err.Message, "G_F_Syk_EditUnsoDecide_GetData");
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                dt = null;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }


        #endregion

        #region "Update"

        /// <summary>
        /// Update Sub Table for T_WK_Syk_EditUnsoDecide_BD
        /// 
        /// Author:Michael
        /// Create Date:2008-11-11
        /// </summary>
        /// <param name="int_Mode">Mode Mode=0 Select All Mode=1 Select Single Row Mode=2 Update Time </param>
        /// <param name="lng_ID">Id Flag</param>
        /// <param name="int_Hiki_FG">Select_FG Value</param>
        /// <param name="str_Unso_CD">Shipper Code</param>
        /// <param name="str_Unso_NM">Shipper Name</param>
        /// <param name="str_Time_CD">Time Code</param>
        /// <param name="str_Time_NM">Time Name</param>
        /// <param name="str_PC_NM">PC Name</param>
        /// <returns>Boolean</returns>
        public static bool G_F_Syk_EditSykData_Sub_Update(int int_Mode, long lng_ID, int int_Hiki_FG, string str_Unso_CD, string str_Unso_NM, string str_Time_CD, string str_Time_NM, string str_PC_NM)
        {
            SqlConnection connect = null;

            try
            {

                //DB接続
                if (!G_CommonClassDB.G_DB_Connect(out connect))
                {
                    //エラーメッセージ表示
                    P_MessageBox_Connection();
                    return false;
                }

                SqlCommand sqlCmd = connect.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[9];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, int_Mode.ToString());
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ID", ParameterDirection.Input, SqlDbType.Int, 0, lng_ID.ToString());
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Hiki_FG", ParameterDirection.Input, SqlDbType.Int, 0, int_Hiki_FG.ToString());
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 25, str_Unso_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_NM", ParameterDirection.Input, SqlDbType.VarChar, 100, str_Unso_NM);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Time_CD", ParameterDirection.Input, SqlDbType.VarChar, 25, str_Time_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Time_NM", ParameterDirection.Input, SqlDbType.VarChar, 50, str_Time_NM);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 25, str_PC_NM);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");
                SqlParameter[] sqloutpara;


                //ストアド実行(帳票出力レコード取得)
                G_CommonClassDB.G_DB_ExecStoredProc(connect, sqlCmd, "USP_PC_F_Syk_EditUnsoDecide_SUB_DataUpdate", sqlPara, out sqloutpara);


                return true;
            }
            catch (Exception err)
            {
                //ログ書込み

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EditSykData_Sub_Update Error" + err.Message, "G_F_Syk_EditSykData_Sub_Update");

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show("G_F_Syk_EditSykData_Sub_Update Error" + err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);

                return false;
            }
            finally
            {
                if (connect != null)
                {
                    //DB開放
                    if (!G_CommonClassDB.G_DB_Dispose(connect))
                    {
                        //エラーメッセージ表示
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        /// <summary>
        /// Update Data 
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_PC_NM">PC Name</param>
        /// <param name="str_Work_CD">Operater Code</param>
        /// <returns>int</returns>
        public static int G_F_Syk_EditSykData_Update(string str_Tori_CD, string str_PC_NM, string str_Work_CD)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[5];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Work_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EditUnsoDecide_DataUpdate", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value);

            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EditSykData_Update" + err.Message, "G_F_Syk_EditSykData_Update");
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                result = -11;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #endregion

        #region"Delivery Method Popup"

        #region"Update"

        public static int G_F_Syk_EditUnsoDecidePopUp_Update(G_CommonClassDBEntry.UnsoDecide unsoDecide)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[31];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ID", ParameterDirection.Input, SqlDbType.Int, 0, unsoDecide.str_ID);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 25, unsoDecide.str_PC_NM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Uria_DT", ParameterDirection.Input, SqlDbType.VarChar, 10, unsoDecide.str_Uria_DT);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Siji_DT", ParameterDirection.Input, SqlDbType.VarChar, 10, unsoDecide.str_Siji_DT);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 10, unsoDecide.str_Unso_CD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_NM", ParameterDirection.Input, SqlDbType.VarChar, 50, unsoDecide.str_Unso_NM);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_CD", ParameterDirection.Input, SqlDbType.VarChar, 10, unsoDecide.str_Todo_CD);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Zip_CD", ParameterDirection.Input, SqlDbType.VarChar, 10, unsoDecide.str_Zip_CD);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tdtel_NO", ParameterDirection.Input, SqlDbType.VarChar, 25, unsoDecide.str_Tdtel_NO);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tdnm_01_NM", ParameterDirection.Input, SqlDbType.VarChar, 100, unsoDecide.str_Tdnm_01_NM);
                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tdnm_02_NM", ParameterDirection.Input, SqlDbType.VarChar, 100, unsoDecide.str_Tdnm_02_NM);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tdad_01_NM", ParameterDirection.Input, SqlDbType.VarChar, 100, unsoDecide.str_Tdad_01_NM);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tdad_02_NM", ParameterDirection.Input, SqlDbType.VarChar, 100, unsoDecide.str_Tdad_02_NM);
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tdad_03_NM", ParameterDirection.Input, SqlDbType.VarChar, 100, unsoDecide.str_Tdad_03_NM);
                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Edom_KB", ParameterDirection.Input, SqlDbType.VarChar, 2, unsoDecide.str_Edom_KB);
                sqlPara[15] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nsai_KB", ParameterDirection.Input, SqlDbType.VarChar, 2, unsoDecide.str_Nsai_KB);
                sqlPara[16] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Hrai_KB", ParameterDirection.Input, SqlDbType.VarChar, 10, unsoDecide.str_Hrai_KB);
                sqlPara[17] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Time_CD", ParameterDirection.Input, SqlDbType.VarChar, 10, unsoDecide.str_Time_CD);
                sqlPara[18] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Time_NM", ParameterDirection.Input, SqlDbType.VarChar, 50, unsoDecide.str_Time_NM);
                sqlPara[19] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Biko1", ParameterDirection.Input, SqlDbType.VarChar, 80, unsoDecide.str_Biko1);
                sqlPara[20] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Biko2", ParameterDirection.Input, SqlDbType.VarChar, 80, unsoDecide.str_Biko2);
                sqlPara[21] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_CD", ParameterDirection.Input, SqlDbType.VarChar, 10, unsoDecide.str_Toku_CD);
                sqlPara[22] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_Zip_No", ParameterDirection.Input, SqlDbType.VarChar, 10, unsoDecide.str_Toku_Zip_No);
                sqlPara[23] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_NM_01", ParameterDirection.Input, SqlDbType.VarChar, 100, unsoDecide.str_Toku_NM_01);
                sqlPara[24] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_NM_02", ParameterDirection.Input, SqlDbType.VarChar, 100, unsoDecide.str_Toku_NM_02);
                sqlPara[25] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_AD_01", ParameterDirection.Input, SqlDbType.VarChar, 100, unsoDecide.str_Toku_AD_01);
                sqlPara[26] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_AD_02", ParameterDirection.Input, SqlDbType.VarChar, 100, unsoDecide.str_Toku_AD_02);
                sqlPara[27] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_AD_03", ParameterDirection.Input, SqlDbType.VarChar, 100, unsoDecide.str_Toku_AD_03);
                sqlPara[28] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_Tel_No", ParameterDirection.Input, SqlDbType.VarChar, 25, unsoDecide.str_Toku_Tel_No);
                sqlPara[29] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Instructions", ParameterDirection.Input, SqlDbType.VarChar, 80, unsoDecide.str_Instructions);
                sqlPara[30] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EditUnsoDecidePopUp_DataUpdate", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value);

            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EditUnsoDecidePopUp_Update Error" + err.Message, "G_F_Syk_EditUnsoDecidePopUp_Update");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                result = -11;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        #endregion

        #endregion

        #region"Issue Delivery Adjustment (PopUp)"

        #region "Search"

        /// <summary>
        /// Issue Delivery Adjustment Location Select Data
        /// 
        /// Author:Michael
        /// Create Date:2008-11-15
        /// </summary>
        /// <param name="str_Mode">Mode</param>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Nins_CD">Shipper Code</param>
        /// <param name="str_Shoh_CD">Product Code</param>
        /// <param name="str_Jyot_KB">Product Condition Code</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Syk_EntrySykDataFB_PopUp_GetData(string str_Mode, string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_Jyot_KB)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[6];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyot_KB);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykDataFB_PopUp_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EntrySykDataFB_PopUp_GetData" + err.Message, "G_F_Syk_EntrySykDataFB_PopUp_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion

        #endregion

        #region"Issue Delivery Adjustment"

        #region "Search"

        /// <summary>
        /// Search Detail Data
        /// 
        /// Author:Michael
        /// Create Date:2008-11-17
        /// </summary>
        /// <param name="str_PC_NM">PC Name</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Syk_EntrySykDataFB_Sub_GetData(string str_PC_NM)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[1];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykDataFB_SUB_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EntrySykDataFB_Sub_GetData Error" + err.Message, "G_F_Syk_EntrySykDataFB_Sub_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        #endregion

        #region"Update"

        /// <summary>
        /// Detail Data Insert 
        /// 
        /// Author:Michael
        /// Create Date:2008-11-17
        /// </summary>
        /// <param name="fb">Issue Delivery Adjustment detail Data Entry</param>
        /// <returns>Int</returns>
        public static int G_F_Syk_EntrySykDataFB_Sub_Update(G_CommonClassDBEntry.EntrySykDataFB fb)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[20];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, fb.str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ID", ParameterDirection.Input, SqlDbType.Int, 0, fb.str_ID);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, fb.str_Tori_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, fb.str_Nins_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Meis_KB", ParameterDirection.Input, SqlDbType.Char, 0, fb.str_Meis_KB);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, fb.str_Souk_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, fb.str_Shoh_CD);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, fb.str_Jyot_KB);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, fb.str_Shoh_NM);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Yote_QT", ParameterDirection.Input, SqlDbType.Int, 0, fb.str_Yote_QT);

                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tani_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, fb.str_Tani_NM);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, fb.str_Loca_CD);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nyuk_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, fb.str_Nyuk_DT);
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Iri_QT", ParameterDirection.Input, SqlDbType.Int, 0, fb.str_Iri_QT);
                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Futa_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, fb.str_Futa_NM);

                sqlPara[15] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_GP);
                sqlPara[16] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                sqlPara[17] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Lot_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, fb.str_Lot_CD);

                sqlPara[18] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, fb.str_PC_NM);
                sqlPara[19] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykDataFB_SUB_DataUpdate", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EntrySykDataFB_Sub_Update Error" + err.Message, "G_F_Syk_EntrySykDataFB_Sub_Update");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        /// <summary>
        /// Master Data Update
        /// 
        /// Author:Michael
        /// Create Date:2008-11-17
        /// </summary>
        /// <param name="str_Mode">Mode</param>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Nins_CD">Shipper Code</param>
        /// <param name="str_PC_NM">PC Name</param>
        /// <param name="str_Work_CD">Operater Code</param>
        /// <returns>Int</returns>
        public static int G_F_Syk_EntrySykDataFB_Update(string str_Mode, string str_Tori_CD, string str_Nins_CD, string str_PC_NM, string str_Work_CD)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[8];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Work_CD);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_GP);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykDataFB_DataInsert", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EntrySykDataFB_Update Error" + err.Message, "G_F_Syk_EntrySykDataFB_Update");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #region"Delete"

        public static int G_F_Syk_EntrySykDataFB_Sub_Delete(string str_Mode, string str_ID, string str_PC_NM)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[4];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ID", ParameterDirection.Input, SqlDbType.Int, 0, str_ID);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;
                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykDataFB_SUB_DataDelete", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Syk_EntrySykDataFB_Sub_Delete Error" + err.Message, "G_F_Syk_EntrySykDataFB_Sub_Delete");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #endregion


        #region"Delivery (JOB) Order Entry"

        #region"Update"

        public static int G_F_Syk_EntryJobOrder_Sub_DataUpdate(string str_Mode, string str_BD_ID, string str_Uria_No, string str_UriaPos_No, string str_Meis_KB, string str_Shoh_CD, string str_Shoh_NM,
                                                               string str_JAN_CD, string str_Yote_QT, string str_Price, string str_CPO_POS, string str_ATI_QT, string str_Jyot_KB, string str_Souk_CD, string str_Lot_NO, string str_FB_NO, string str_Line_No_Internal)
        {

            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[19];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@BD_ID", ParameterDirection.Input, SqlDbType.Int, 0, str_BD_ID);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Uria_No", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Uria_No);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@UriaPos_No", ParameterDirection.Input, SqlDbType.Int, 0, str_UriaPos_No);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Meis_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Meis_KB);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_NM);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@JAN_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_JAN_CD);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Yote_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Yote_QT);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Price", ParameterDirection.Input, SqlDbType.Int, 0, str_Price);

                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@CPO_POS", ParameterDirection.Input, SqlDbType.VarChar, 0, str_CPO_POS);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ATI_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_ATI_QT);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyot_KB);
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Souk_CD);
                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Lot_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Lot_NO);

                sqlPara[15] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[16] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[17] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Line_No_Internal", ParameterDirection.Input, SqlDbType.Int, 0, str_Line_No_Internal);
                sqlPara[18] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrder_Sub_Update", sqlPara, out sqloutPara);


                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                return result;
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static int G_F_Syk_EntryJobOrder_Sub_DataDelete()
        {
            int result = -1;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[2];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrder_Sub_Delete", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());
                return result;
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static DataTable G_F_Syk_EntryJobOrder_Sub_DataSelect()
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[1];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrder_Sub_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static int G_F_Syk_EntryJobOrder_DataUpdate(string str_Mode, string str_FB_NO, string str_Tori_CD, string str_Uria_No, string str_Toku_NM_01, string str_Toku_Zip_No, string str_Toku_AD_01, string str_Unso_CD, string str_Nouk_DT, string str_Jytu_DT, string str_Siji_DT, string str_Bik_01_TXT, DataTable dt_SO, DataTable dt_Packing)
        {
            int result = -1;
            SqlConnection sqlConnection = null;

            SqlTransaction tran = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }

                tran = sqlConnection.BeginTransaction();

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[18];

                sqlCommand.Transaction = tran;

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Uria_No", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Uria_No);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_NM_01", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Toku_NM_01);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_Zip_No", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Toku_Zip_No);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_AD_01", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Toku_AD_01);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Unso_CD);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nouk_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nouk_DT);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jytu_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jytu_DT);

                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Siji_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Siji_DT);
                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Bik_01_TXT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Bik_01_TXT);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_GP);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_WorkCD);
                sqlPara[15] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[16] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");
                sqlPara[17] = G_CommonClassDB.G_DB_SetSQLDBParameter("@newFB_NO", ParameterDirection.Output, SqlDbType.Int, 0, str_FB_NO);

                SqlParameter[] sqloutPara;

                //G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrder_DataUpdate", sqlPara, out sqloutPara);

                //result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                //str_FB_NO = sqloutPara[1].Value.ToString();


                sqlCommand.CommandText = "USP_PC_F_Syk_EntryJobOrder_DataUpdate";
                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;
                for (int i = 0; i < sqlPara.Length; i++)
                {
                    sqlCommand.Parameters.Add(sqlPara[i]);
                }

                sqlCommand.ExecuteNonQuery();

                result = Convert.ToInt32(sqlPara[16].Value.ToString());
                str_FB_NO = sqlPara[17].Value.ToString();

                //Delete Data
                if (result == 0)
                {
                    sqlCommand.Parameters.Clear();

                    sqlPara = new SqlParameter[2];
                    sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                    sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                    //G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrder_Ref_Delete", sqlPara, out sqloutPara);
                    sqlCommand.CommandText = "USP_PC_F_Syk_EntryJobOrder_Ref_Delete";
                    sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;
                    for (int i = 0; i < sqlPara.Length; i++)
                    {
                        sqlCommand.Parameters.Add(sqlPara[i]);
                    }

                    sqlCommand.ExecuteNonQuery();

                }
      
                if ((result == 0) && (str_Mode != "2"))
                {

                    SqlBulkCopy sqlBulk = new SqlBulkCopy(sqlConnection, SqlBulkCopyOptions.Default, tran);

                    if ((dt_SO != null) && (dt_SO.Rows.Count > 0))
                    {
                        foreach (DataRow Row in dt_SO.Rows)
                        {
                            Row["FB_NO"] = str_FB_NO;
                        }
                        sqlBulk.ColumnMappings.Clear();
                        sqlBulk.DestinationTableName = "T_PAS_REFSO";
                        sqlBulk.ColumnMappings.Add("FB_NO", "FB_NO");
                        sqlBulk.ColumnMappings.Add("Jyht_NO", "Jyht_NO");
                        sqlBulk.WriteToServer(dt_SO);
                    }

                    if ((dt_Packing != null) && (dt_Packing.Rows.Count > 0))
                    {
                        foreach (DataRow Row in dt_Packing.Rows)
                        {
                            Row["FB_NO"] = str_FB_NO;
                        }
                        sqlBulk.ColumnMappings.Clear();
                        sqlBulk.DestinationTableName = "T_PAS_REFPK";
                        sqlBulk.ColumnMappings.Add("FB_NO", "FB_NO");
                        sqlBulk.ColumnMappings.Add("Packing_CD", "Packing_CD");
                        sqlBulk.ColumnMappings.Add("Packing_NM", "Packing_NM");
                        sqlBulk.WriteToServer(dt_Packing.Select("", "Packing_CD"));
                    }

                }

                if (result == 0)
                {
                    tran.Commit();
                }
                else
                {
                    tran.Rollback();
                }

                return result;
            }
            catch (Exception err)
            {
                tran.Rollback();
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);

                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);

                return -999;
            }
            finally
            {
                if (sqlConnection != null)
                {

                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #region "Select"

        public static DataTable G_F_Syk_EntryJobOrder_DataSelect(string str_FB_NO, string str_Mode)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = new DataSet();
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[2];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrder_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

                return dt;
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static int G_F_Syk_EntryJobOrder_Sub_DataInsert(string str_FB_NO)
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrder_Sub_DataInsert", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());
                return result;
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static DataTable G_F_Syk_EntryJobOrder_SUB_DataSelect()
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = new DataSet();
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrder_Sub_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

                return dt;
            }
            catch (Exception err)
            {
                string str_Catpion = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Catpion, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static DataTable G_F_Syk_EntryJobOrder_SUB_DataSelect_Packing(string str_FB_NO)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = new DataSet();
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrder_Sub_DataSelect_Packing", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

                return dt;
            }
            catch (Exception err)
            {
                string str_Catpion = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Catpion, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }


        public static DataTable G_F_Syk_EntryJobOrder_SUB_DataSelect_SONO(string str_FB_NO)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = new DataSet();
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrder_Sub_DataSelect_SONO", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

                return dt;
            }
            catch (Exception err)
            {
                string str_Catpion = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Catpion, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }


        public static int G_F_Syk_EntryJobOrder_Sub_DataCheck(string str_FB_NO)
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[2];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
              
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrder_Sub_DataCheck", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());
                return result;
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #endregion

        #region "Delivery (JOB) Order Entry 2"

        #region "Select"


        public static DataTable G_F_Syk_EntryJobOrder2_DataSelect(string str_FB_NO, string str_Mode)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = new DataSet();
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[2];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrderTwo_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

                return dt;
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static int G_F_Syk_EntryJobOrder2_Sub_DataInsert(string str_FB_NO)
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrderTwo_Sub_DataInsert", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());
                return result;
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static DataTable G_F_Syk_EntryJobOrder2_SUB_DataSelect()
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = new DataSet();
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrderTwo_Sub_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

                return dt;
            }
            catch (Exception err)
            {
                string str_Catpion = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Catpion, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }


        #endregion


        #region "Update"

        public static int G_F_Syk_EntryJobOrder2_Sub_DataUpdate(string str_Mode, string str_BD_ID, string str_Uria_No, string str_UriaPos_No, string str_Meis_KB, string str_Shoh_CD, string str_Shoh_NM,
                                                       string str_JAN_CD, string str_Yote_QT, string str_Price, string str_CPO_POS, string str_ATI_QT, string str_Jyot_KB, string str_Souk_CD, string str_Lot_NO, string str_FB_NO, string str_Line_No_Internal, string str_Cust_PO, string str_Futa_NM, string str_Cust_CD,string str_Line_MK)
        {

            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[23];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@BD_ID", ParameterDirection.Input, SqlDbType.Int, 0, str_BD_ID);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Uria_No", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Uria_No);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@UriaPos_No", ParameterDirection.Input, SqlDbType.Int, 0, str_UriaPos_No);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Meis_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Meis_KB);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_NM);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@JAN_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_JAN_CD);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Yote_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Yote_QT);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Price", ParameterDirection.Input, SqlDbType.Int, 0, str_Price);

                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@CPO_POS", ParameterDirection.Input, SqlDbType.VarChar, 0, str_CPO_POS);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ATI_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_ATI_QT);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyot_KB);
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Souk_CD);
                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Lot_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Lot_NO);

                sqlPara[15] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[16] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[17] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Line_No_Internal", ParameterDirection.Input, SqlDbType.Int, 0, str_Line_No_Internal);
                sqlPara[18] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_PO", ParameterDirection.Input, SqlDbType.VarChar, 0,str_Cust_PO);
                sqlPara[19] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Futa_NM", ParameterDirection.Input, SqlDbType.VarChar,0, str_Futa_NM);
                sqlPara[20] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_CD", ParameterDirection.Input, SqlDbType.VarChar,0, str_Cust_CD);
                sqlPara[21] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Line_MK", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Line_MK);
                sqlPara[22] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrderTwo_Sub_Update", sqlPara, out sqloutPara);


                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                return result;
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }


        public static int G_F_Syk_EntryJobOrder2_DataUpdate(string str_Mode, string str_FB_NO, string str_Tori_CD, string str_Uria_No, string str_Toku_NM_01, string str_Toku_Zip_No, string str_Toku_AD_01, string str_Unso_CD, string str_Nouk_DT, string str_Jytu_DT, string str_Siji_DT, string str_Bik_01_TXT, string str_Tdnm_01_NM,string str_Tdad_01_NM, DataTable dt_SO)
        {
            int result = -1;
            SqlConnection sqlConnection = null;

            SqlTransaction tran = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }

                tran = sqlConnection.BeginTransaction();

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[20];

                sqlCommand.Transaction = tran;

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Uria_No", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Uria_No);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_NM_01", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Toku_NM_01);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_Zip_No", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Toku_Zip_No);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_AD_01", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Toku_AD_01);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Unso_CD);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nouk_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nouk_DT);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jytu_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jytu_DT);

                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Siji_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Siji_DT);
                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Bik_01_TXT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Bik_01_TXT);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_GP);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_WorkCD);
                sqlPara[15] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[16] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tdnm_01_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tdnm_01_NM);
                sqlPara[17] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tdad_01_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tdad_01_NM);
                sqlPara[18] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");
                sqlPara[19] = G_CommonClassDB.G_DB_SetSQLDBParameter("@newFB_NO", ParameterDirection.Output, SqlDbType.Int, 0, str_FB_NO);

                SqlParameter[] sqloutPara;

                //G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrder_DataUpdate", sqlPara, out sqloutPara);

                //result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                //str_FB_NO = sqloutPara[1].Value.ToString();


                sqlCommand.CommandText = "USP_PC_F_Syk_EntryJobOrderTwo_DataUpdate";
                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;
                for (int i = 0; i < sqlPara.Length; i++)
                {
                    sqlCommand.Parameters.Add(sqlPara[i]);
                }

                sqlCommand.ExecuteNonQuery();

                result = Convert.ToInt32(sqlPara[18].Value.ToString());
                str_FB_NO = sqlPara[19].Value.ToString();

                //Delete Data
                if (result == 0)
                {
                    sqlCommand.Parameters.Clear();

                    sqlPara = new SqlParameter[2];
                    sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                    sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                    //G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntryJobOrder_Ref_Delete", sqlPara, out sqloutPara);
                    sqlCommand.CommandText = "USP_PC_F_Syk_EntryJobOrder_Ref_Delete";
                    sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;
                    for (int i = 0; i < sqlPara.Length; i++)
                    {
                        sqlCommand.Parameters.Add(sqlPara[i]);
                    }

                    sqlCommand.ExecuteNonQuery();

                }

                if ((result == 0) && (str_Mode != "2"))
                {

                    SqlBulkCopy sqlBulk = new SqlBulkCopy(sqlConnection, SqlBulkCopyOptions.Default, tran);

                    if ((dt_SO != null) && (dt_SO.Rows.Count > 0))
                    {
                        foreach (DataRow Row in dt_SO.Rows)
                        {
                            Row["FB_NO"] = str_FB_NO;
                        }
                        sqlBulk.ColumnMappings.Clear();
                        sqlBulk.DestinationTableName = "T_PAS_REFSO";
                        sqlBulk.ColumnMappings.Add("FB_NO", "FB_NO");
                        sqlBulk.ColumnMappings.Add("Jyht_NO", "Jyht_NO");
                        sqlBulk.WriteToServer(dt_SO);
                    }

                    //if ((dt_Packing != null) && (dt_Packing.Rows.Count > 0))
                    //{
                    //    foreach (DataRow Row in dt_Packing.Rows)
                    //    {
                    //        Row["FB_NO"] = str_FB_NO;
                    //    }
                    //    sqlBulk.ColumnMappings.Clear();
                    //    sqlBulk.DestinationTableName = "T_PAS_REFPK";
                    //    sqlBulk.ColumnMappings.Add("FB_NO", "FB_NO");
                    //    sqlBulk.ColumnMappings.Add("Packing_CD", "Packing_CD");
                    //    sqlBulk.ColumnMappings.Add("Packing_NM", "Packing_NM");
                    //    sqlBulk.WriteToServer(dt_Packing.Select("", "Packing_CD"));
                    //}

                }

                if (result == 0)
                {
                    tran.Commit();
                }
                else
                {
                    tran.Rollback();
                }

                return result;
            }
            catch (Exception err)
            {
                tran.Rollback();
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);

                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);

                return -999;
            }
            finally
            {
                if (sqlConnection != null)
                {

                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }


        #endregion

        #endregion

        #endregion

        #region"Stock "

        #region"Stock Deduction Auto"

        #region"Search"

        /// <summary>
        /// Search the first Insert data
        /// 
        /// Author:Michael
        /// Create Date:2008-11-12
        /// </summary>
        /// <param name="str_PC_NM">PC Name</param>
        /// <param name="str_Uria_DT">Invoice Date</param>
        /// <param name="str_Attribute_CD">Attribute Code</param>
        /// <returns>Boolean</returns>
        public static bool G_F_Mortgage_Sub_Insert(string str_PC_NM, string str_Uria_DT, string str_Attribute_CD, string str_Souk_CD)
        {

            bool isSuccess = false;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return false;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[6];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Uria_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Uria_DT);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Attribute_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Attribute_CD);

                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Souk_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                //sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Mortgage_SUB_DataInsert", sqlPara, out sqloutPara);


                if (Convert.ToInt32(sqloutPara[0].Value) == 0)
                {
                    isSuccess = true;
                }
            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Mortgage_Sub_Insert" + err.Message, "G_F_Mortgage_Sub_Insert");
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return isSuccess;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return isSuccess;
        }

        /// <summary>
        /// Search The second Inquary Data
        /// 
        /// 
        /// Author:Michael
        /// Create Date:2008-11-12
        /// </summary>
        /// <param name="str_PC_NM">PC Name</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Mortgage_GetData(string str_PC_NM)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;


                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Mortgage_SUB_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Mortgage_GetData" + err.Message, "G_F_Mortgage_GetData");
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                dt = null;
                return dt;
            }

            return dt;
        }

        /// <summary>
        /// Print Picking List Data
        /// </summary>
        /// <param name="str_Pic_No">Pic No</param>
        /// <param name="str_PC_NM">PC Name</param>
        /// <returns></returns>
        public static DataTable G_F_Mortgage_PrintPickingList_GetData(string str_Pic_No, string str_PC_NM)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[2];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Pic_No", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Pic_No);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_R_PickingList_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Mortgage_PrintPickingList_GetData Error", "G_F_Mortgage_PrintPickingList_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion

        #region"Update"

        /// <summary>
        /// Update Hiki_FG status to T_Mortgage_Siji 
        /// 
        /// 
        /// Author:Michael
        /// Create Date:2008-11-12
        /// </summary>
        /// <param name="str_Mode">Mode</param>
        /// <param name="str_ID">ID</param>
        /// <param name="str_Hiki_FG">Hiki_FG</param>
        /// <param name="str_PC_NM">PC Name</param>
        /// <returns>Boolean</returns>
        public static bool G_F_Mortgage_Sub_Update(string str_Mode, string str_ID, string str_Hiki_FG, string str_PC_NM)
        {
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[5];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ID", ParameterDirection.Input, SqlDbType.Int, 0, str_ID);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Hiki_FG", ParameterDirection.Input, SqlDbType.Int, 0, str_Hiki_FG);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Mortgage_SUB_DataUpDate", sqlPara, out sqloutPara);

            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Mortgage_Sub_Update Error" + err.Message, "G_F_Mortgage_Sub_Update");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return true;
        }

        #endregion

        #region"Execute"

        /// <summary>
        /// Insert data T_PAS_XXX 
        /// </summary>
        /// <param name="str_PC_NM">PC Name</param>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Syk_DT">Invoice Date</param>
        /// <param name="str_Packing">Packing Flag</param>
        /// <param name="int_Tran_KB"></param>
        /// <returns>Boolean</returns>
        public static bool G_F_Mortgage_ExecHikiate(string str_PC_NM, string str_Tori_CD, string str_Syk_DT, string str_Packing, int int_Tran_KB)
        {
            bool isSuccess = false;
            string str_Message = string.Empty;
            string str_Caption = string.Empty;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return isSuccess;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                sqlCommand.CommandTimeout = 300;
                SqlParameter[] sqlPara = new SqlParameter[7];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 25, G_CommonDefine.G_PCNM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 10, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unyo_DT", ParameterDirection.Input, SqlDbType.SmallDateTime, 10, str_Syk_DT);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sden_KB", ParameterDirection.Input, SqlDbType.VarChar, 1, str_Packing);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_WorkCD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Req_Tran_KB", ParameterDirection.Input, SqlDbType.Int, 10, int_Tran_KB.ToString());
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Mortgage_PAS_DataInsert", sqlPara, out sqloutPara);

                int result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                switch (result)
                {
                    case 0:
                        isSuccess = true;
                        break;
                    case 77:
                        //MessageBox.Show("懠張棟偱堷摉偑幚峴偝傟偰偄傑偡丅", "妋擣乕", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        isSuccess = false;
                        str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                        str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Other_PC_User);
                        MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    case 99:
                        //MessageBox.Show("僄儔乕偑敪惗偟傑偟偨丅", "妋擣乕", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        isSuccess = false;
                        str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                        str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Erroroccurred);
                        MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    default:
                        break;
                }

            }
            catch (Exception err)
            {

                string str_Catpion = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Mortgage_ExecHikiate ERROR" + err.Message, "G_F_Mortgage_ExecHikiate");
                MessageBox.Show(err.Message, str_Catpion, MessageBoxButtons.OK, MessageBoxIcon.Error);
                isSuccess = false;
                return isSuccess;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return isSuccess;
        }

        /// <summary>
        /// Insert data to T_PCI_XXX
        /// </summary>
        /// <param name="str_PC_NM">PC Name</param>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <returns>Boolean</returns>
        public static bool G_F_Mortgage_ExtractPikingData(string str_PC_NM, string str_Tori_CD)
        {

            SqlConnection sqlConnection = null;

            bool isSuccess = false;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return isSuccess;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                sqlCommand.CommandTimeout = 300;
                SqlParameter[] sqlPara = new SqlParameter[4];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 25, str_PC_NM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 10, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_WorkCD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Mortgage_PIC_DataInsert", sqlPara, out sqloutPara);

                int result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                switch (result)
                {
                    case 0:
                        isSuccess = true;
                        break;
                    default:
                        string str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_InsertFail);
                        string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                        MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        isSuccess = false;
                        break;
                }

            }
            catch (Exception err)
            {

                string str_Catpion = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Mortgage_ExecHikiate ERROR" + err.Message, "G_F_Mortgage_ExecHikiate");
                MessageBox.Show(err.Message, str_Catpion, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            return isSuccess;
        }

        /// <summary>
        /// Get Data Packing 
        /// </summary>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Mortgage_GetDataPacking()
        {

            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Mortgage_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Catpion = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Mortgage_ExecHikiate ERROR" + err.Message, "G_F_Mortgage_ExecHikiate");
                MessageBox.Show(err.Message, str_Catpion, MessageBoxButtons.OK, MessageBoxIcon.Error);
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion

        #endregion

        #region"Deduction Grouping Edit"

        #region"Search"

        /// <summary>
        /// Search the first setp delete data
        /// 
        /// Author:Michael
        /// Create Date:2008-11-13
        /// </summary>
        /// <param name="str_Mode">Mode</param>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_PC_NM">PC Name</param>
        /// <returns>Boolean</returns>
        public static bool G_F_Mortgage_GrainDecide_Delete(string str_Mode, string str_Tori_CD, string str_PC_NM)
        {
            bool isSuccess = false;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return isSuccess;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[4];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@RET", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Mortgage_GrainDecide_DataDelete", sqlPara, out sqloutPara);

                isSuccess = true;
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Mortgage_GrainDecide_Delete" + err.Message, "G_F_Mortgage_GrainDecide_Delete");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return isSuccess;
        }

        /// <summary>
        /// Search the second step Insert Data
        /// 
        /// 
        /// Author: Michael
        /// Create Date:2008-11-13
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Datetype">Date Type</param>
        /// <param name="str_Target_DT">Date Value</param>
        /// <param name="str_Attribute_CD">Attribute Code</param>
        /// <param name="str_Tokki_KB">Remark Type</param>
        /// <param name="str_Unso_CD">Delivery Method Code</param>
        /// <param name="str_PC_NM">PC Name</param>
        /// <returns>Boolean</returns>
        public static bool G_F_Mortgage_GrainDecide_Insert(string str_Tori_CD, string str_Datetype, string str_Target_DT, string str_Attribute_CD, string str_Tokki_KB, string str_Unso_CD, string str_PC_NM)
        {
            bool isSuccess = false;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return isSuccess;
                }

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[8];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@TOri_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Datetype", ParameterDirection.Input, SqlDbType.Int, 0, str_Datetype);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Target_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Target_DT);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Attribute_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Attribute_CD);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tokki_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tokki_KB);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Unso_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Mortgage_GrainDecide_DataInsert", sqlPara, out sqloutPara);

                int result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                switch (result)
                {
                    case 0:
                        isSuccess = true;
                        break;
                    case -1:

                        //string str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_InsertFail);
                        //string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                        //MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);

                        isSuccess = false;
                        break;
                    default:
                        isSuccess = false;
                        break;
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Mortgage_GrainDecide_Insert Error " + err.Message, "G_F_Mortgage_GrainDecide_Insert");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            return isSuccess;
        }

        /// <summary>
        /// Search the three get data
        /// </summary>
        /// <returns></returns>
        public static DataTable G_F_Mortgage_GrainDecide_GetData(string str_PC_NM, string str_OrderBy)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[2];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@OrderBy", ParameterDirection.Input, SqlDbType.Int, 0, str_OrderBy);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Mortgage_GrainDecide_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Mortgage_GrainDecide_GetData Error" + err.Message, "G_F_Mortgage_GrainDecide_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion

        #region"Clear"



        #endregion

        #region"Update"

        /// <summary>
        /// Update Data
        /// 
        /// Author:Michael
        /// Create Date:2008-11-13
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_PC_NM">PC Name</param>
        /// <param name="str_Work_CD">Operater Code</param>
        /// <returns>Boolean</returns>
        public static bool G_F_Mortgage_GrainDecide_Update(string str_Tori_CD, string str_PC_NM, string str_Work_CD)
        {
            bool isSuccess = false;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return false;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[4];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Work_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Mortgage_GrainDecide_DataUpdate", sqlPara, out sqloutPara);

                int result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                if (result == 0)
                {
                    isSuccess = true;
                }
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Mortgage_GrainDecide_Update Error" + err.Message, "G_F_Mortgage_GrainDecide_Update");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);

                return false;
            }

            return isSuccess;
        }


        public static bool G_F_Mortgage_GrainDecide_Sub_Update(string str_ID, string str_Hiki_FG, string str_PC_NM)
        {
            bool isSuccess = false;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return false;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[4];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ID", ParameterDirection.Input, SqlDbType.Int, 0, str_ID);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Hiki_FG ", ParameterDirection.Input, SqlDbType.Int, 0, str_Hiki_FG);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Mortgage_GrainDecide_SUB_DataUpdate", sqlPara, out sqloutPara);

                int result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                if (result == 0)
                {
                    isSuccess = true;
                }
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Mortgage_GrainDecide_Sub_Update Error" + err.Message, "G_F_Mortgage_GrainDecide_Sub_Update");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);

                return false;
            }

            return isSuccess;
        }

        #endregion

        #endregion

        #region"Auto Stock Deduction For Bonded"

        #region"Search"

        /// <summary>
        /// Get Customer Code
        /// </summary>
        /// <returns></returns>
        public static DataTable G_F_Syk_StockAllocation_GetCustomerCode()
        {
            SqlConnection sqlConnection = null;
            DataTable dt = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, out ds, "USP_COM_M_Customer_DataSelect");

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        /// <summary>
        /// Get Location Information
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Shoh_CD">Product Code</param>
        /// <param name="str_Section_Code">Section Code</param>
        /// <param name="str_Souk_CD">Warehouse Code</param>
        /// <returns></returns>
        public static DataTable G_F_Syk_StockAllocation_GetLoca(string str_Tori_CD, string str_Shoh_CD, string str_Section_Code, string str_Souk_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[4];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Section_Code);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Souk_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockAllocationLoca_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        /// <summary>
        /// Get Detail Data
        /// </summary>
        /// <param name="str_PC_NM">PC Name</param>
        /// <param name="str_Cust_NO">Invoice No</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Syk_StockAllocation_GetDetailData(string str_PC_NM, string str_Cust_NO)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[2];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_NO);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockAllocationLoca_Sub_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion

        #region "Update"

        /// <summary>
        /// Stock Deduction For Bonded Detail Update
        /// </summary>
        /// <param name="syk"></param>
        /// <returns>
        /// Author:Michael
        /// 
        /// Date:2009-02-13
        /// </returns>
        public static int G_F_Syk_StockAllocation_Sub_DataUpdate(G_CommonClassDBEntry.SykStockAllocationSub syk)
        {
            int result = 999;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[16];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, syk.str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Id", ParameterDirection.Input, SqlDbType.Int, 0, syk.str_Id);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Loca_Id", ParameterDirection.Input, SqlDbType.Int, 0, syk.str_Loca_Id);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Cust_NO);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Tori_CD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Nins_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Shoh_CD);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Jyot_KB);

                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Souk_CD);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nyuk_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Nyuk_DT);
                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Loca_CD);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Yote_QT", ParameterDirection.Input, SqlDbType.Int, 0, syk.str_Yote_QT);

                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Group_NM);
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_SECTION_CODE);
                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_PC_NM);
                sqlPara[15] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockAllocationLoca_Sub_DataUpdate", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

            }
            catch (Exception ex)
            {
                string str_Catpion = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Catpion, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        /// <summary>
        /// Stock Deduction for Bonded data update
        /// </summary>
        /// <param name="syk"></param>
        /// <returns></returns>
        public static int G_F_Syk_StockAllocation_DataUpdate(G_CommonClassDBEntry.SykStockAllocation syk)
        {
            int result = -1000;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[13];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, syk.str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@NYK_Mode", ParameterDirection.Input, SqlDbType.Int, 0, syk.str_NYK_Mode);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Tori_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Nins_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Section_Code);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Group_NM);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Cust_NO);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Siji_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Siji_DT);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@From_Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_From_Souk_CD);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@TO_Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_TO_Souk_CD);

                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_PC_NM);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, syk.str_Work_CD);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockAllocation_DataUpdate", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #region"Delete"

        /// <summary>
        /// Delete Stock Deduction for Bondad Input Data
        /// </summary>
        /// <param name="str_PC_NM">PC Name</param>
        /// <returns></returns>
        public static bool G_F_Syk_StockAllocation_Sub_DataDelete(string str_PC_NM)
        {
            bool isSuccess = false;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    return isSuccess;
                }

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[2];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.VarChar, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockAllocationLoca_Sub_DataDelete", sqlPara, out sqloutPara);

                if (sqloutPara[0].Value.ToString().Equals("0"))
                {
                    isSuccess = true;
                }
            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            return isSuccess;
        }

        #endregion

        #endregion

        #region "Stock Deduction by Selection"

        #region "Search"

        public static DataTable G_F_Syk_StockDuctionByJOB_GetInvoiceNo()
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockDuctionByJOB_GetInvoiceNo", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static DataTable G_F_Syk_StockDuctionByJOB_GetData(string str_Section_Code, string str_Siji_DT, string str_Cust_NO,string str_Sort_Mode)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[4];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Section_Code);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Siji_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Siji_DT);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_NO);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sort_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Sort_Mode);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockDuctionByJOB_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

                return dt;

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static DataTable G_F_Syk_StockDuctionByProduct_GetData(string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_Lot_CD, string str_Jyot_KB, string str_Souk_CD, string str_Section_Code, string str_FB_NO, string str_FBPOS_NO)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[10];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Lot_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Lot_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyot_KB);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Souk_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Section_Code);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FBPOS_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FBPOS_NO);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockDuctionByProduct_GetData", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static int G_F_Syk_StockDuctionByJOB_GetDataCheck()
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_NM", ParameterDirection.Input, SqlDbType.VarChar, 50, G_CommonDefine.G_str_Customer_GP);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@RET", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockDuctionByJOB_Check", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());
                return result;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static int G_F_Syk_StockDuctionByJOB_GetDataCheckCancel()
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_NM", ParameterDirection.Input, SqlDbType.VarChar, 50, G_CommonDefine.G_str_Customer_GP);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@RET", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockDuctionByJOB_CheckCancel", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());
                return result;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static DataTable G_F_Syk_StockDuctionByJOB_GetDetailInputCheck(string str_FB_NO, string str_FBPOS_NO)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                DataSet ds = null;
                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FBPOS_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FBPOS_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockDuctionByJOB_ProductCheck", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

                return dt;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonDefine.G_Message_Error;
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        /// <summary>
        /// Get ETA Nouk_DT Date
        /// </summary>
        /// <param name="str_Cust_NO"></param>
        /// <returns></returns>
        public static void G_F_Syk_StockDuctionByJOB_GetNouk_DT(string str_Cust_NO,ref string Nouk_DT,ref string str_Siji_DT)
        {
            

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                
                }
                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[2];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockDuctionByJOB_GetNouk_DT", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    Nouk_DT = ds.Tables[0].Rows[0][0].ToString();
                    str_Siji_DT = ds.Tables[0].Rows[0][1].ToString();
                }
              
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
               
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #region "Delete"

        public static int G_F_Syk_StockDuctionByProduct_DataDelete()
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[2];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockDuctionByProduct_DataDelete", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                return result;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }


        public static int G_F_Syk_StockDuctionByJOB_Sub_DataDelete()
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[2];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@RET", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockDuctionByJOB_Sub_DataDelete", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());
                return result;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static int G_F_Syk_StockDuctionByProduct_SUB_DataDelete(string str_FB_NO, string str_FBPOS_NO)
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[4];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FBPOS_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FBPOS_NO);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");


                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockDuctionByProduct_SUB_DataDelete", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                return result;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #region"Update"

        public static int G_F_Syk_StockDuctionByJOB_DataUpdate(DataTable dt_FB, string str_Tori_CD,out DataTable dtPOS)
        {
            string str_Caption = string.Empty;
            string str_Message = string.Empty;

            int result = -1;
            SqlConnection sqlConnection = null;
            SqlTransaction tran = null;

            dtPOS = new DataTable();

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                //Insert FB_NO DATA
                tran = sqlConnection.BeginTransaction(IsolationLevel.RepeatableRead);
                sqlCommand.Transaction = tran;

                SqlBulkCopy sqlCopy = new SqlBulkCopy(sqlConnection, SqlBulkCopyOptions.Default, tran);
                sqlCopy.BatchSize = 100;
                sqlCopy.ColumnMappings.Add("PC_NM", "PC_NM");
                sqlCopy.ColumnMappings.Add("FB_NO", "FB_NO");
                sqlCopy.ColumnMappings.Add("FBPOS_NO", "FBPOS_NO");
                sqlCopy.DestinationTableName = "T_WK_Syk_StockDuctionByJOB_FBNO";
                sqlCopy.WriteToServer(dt_FB);

                SqlParameter[] sqlPara = new SqlParameter[7];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unyo_DT", ParameterDirection.Input, SqlDbType.SmallDateTime, 0, DateTime.Now.ToString("yyyy-MM-dd"));
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sden_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, "0");

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_WorkCD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Req_Tran_KB", ParameterDirection.Input, SqlDbType.Int, 0, "0");
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                //SqlParameter[] sqloutPara;

                //G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockDuctionByJOB_DataUpdate", sqlPara, out sqloutPara);
                sqlCommand.CommandText = "USP_PC_F_Syk_StockDuctionByJOB_DataUpdate";
                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;
                for (int i = 0; i < sqlPara.Length; i++)
                {
                    sqlCommand.Parameters.Add(sqlPara[i]);
                }

                sqlCommand.ExecuteNonQuery();


                result = Convert.ToInt32(sqlPara[6].Value.ToString());

                if (result != 0)
                {
                    tran.Rollback();

                    switch (result)
                    {
                        case 0:

                            break;
                        case 77:


                            str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                            str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Other_PC_User);
                            MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            break;
                        case 99:

                            str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Information);
                            str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_StockDeductionFailed);
                            MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            break;
                        default:
                            break;
                    }

                    return result;
                }

                sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 50, G_CommonDefine.G_PCNM);

                sqlCommand.Parameters.Clear();
                sqlCommand.Parameters.Add(sqlPara[0]);

                sqlCommand.CommandText = "USP_PC_F_Syk_StockDuctionByJOB_GetData_FailPOS";
                sqlCommand.CommandType = CommandType.StoredProcedure;

                SqlDataReader dr = sqlCommand.ExecuteReader();

                dtPOS.Columns.Add("FB_NO", typeof(int));
                dtPOS.Columns.Add("FBPOS_NO", typeof(int));

                while (dr.Read())
                {
                    DataRow Row = dtPOS.NewRow();

                    Row["FB_NO"] = Convert.ToInt32(dr["FB_NO"].ToString());
                    Row["FBPOS_NO"] = Convert.ToInt32(dr["FBPOS_NO"].ToString());

                    dtPOS.Rows.Add(Row);
                }
                dr.Close();
                dr.Dispose();


                if (dtPOS.Rows.Count > 0)
                {
                    tran.Rollback();
                    str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Information);
                    str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_StockDeductionFailed);
                    MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    result = 99;
                    return result;
                }


                sqlPara = new SqlParameter[4];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_WorkCD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                //sqloutPara = null;
                //G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Mortgage_PIC_DataInsert", sqlPara, out sqloutPara);
                sqlCommand.Parameters.Clear();
                sqlCommand.CommandText = "USP_PC_F_Syk_StockDuctionByJOB_PIC_DataInsert";
                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;
                for (int i = 0; i < sqlPara.Length; i++)
                {
                    sqlCommand.Parameters.Add(sqlPara[i]);
                }

                sqlCommand.ExecuteNonQuery();

                result = Convert.ToInt32(sqlPara[3].Value.ToString());
                if (result != 0)
                {
                    tran.Rollback();
                    switch (result)
                    {
                        case 0:

                            break;
                        default:
                            str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_InsertFail);
                            str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                            MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);

                            break;
                    }
                    return result;
                }

                tran.Commit();

                return result;
            }
            catch (Exception err)
            {
                if (tran != null)
                {
                    tran.Rollback();
                }
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                result = 99;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static int G_F_Syk_StockDuctionByProduct_DataUpdate(DataTable dt)
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            SqlTransaction tran = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                tran = sqlConnection.BeginTransaction();

                SqlBulkCopy sqlCopy = new SqlBulkCopy(sqlConnection, SqlBulkCopyOptions.Default, tran);
                sqlCopy.BatchSize = 100;
                sqlCopy.ColumnMappings.Add("PC_NM", "PC_NM");
                sqlCopy.ColumnMappings.Add("FB_NO", "FB_NO");
                sqlCopy.ColumnMappings.Add("FBPOS_NO", "FBPOS_NO");
                sqlCopy.ColumnMappings.Add("Shoh_CD", "Shoh_CD");
                sqlCopy.ColumnMappings.Add("Shoh_NM", "Shoh_NM");
                sqlCopy.ColumnMappings.Add("Yote_QT", "Yote_QT");
                sqlCopy.ColumnMappings.Add("M_LoStock_ID", "M_LoStock_ID");
                sqlCopy.ColumnMappings.Add("Pick_QT", "Pick_QT");

                sqlCopy.DestinationTableName = "T_WK_StockDuctionByProduct";

                sqlCopy.WriteToServer(dt);

                tran.Commit();

                result = 0;
                return result;
            }
            catch (Exception err)
            {
                if (tran != null)
                {
                    tran.Rollback();
                }
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #endregion

        #region "Reconvery Data"

        public static DataTable G_F_Syk_StockDeductionRecovery_GetInvoiceNo()
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockDeductionRecovery_GetInvoiceNo", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        /// <summary>
        /// Update Stock deduction flag to 0
        /// </summary>
        /// <returns></returns>
        public static int G_F_Syk_StockDeductionRecover_UpdateFlag()
        {

            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[2];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_StockDeductionRecovery_UpdateFlag", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                return result;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }


        public static int G_F_Syk_StockDeductionRecover_ReconveryData(string str_FB_NO)
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_FB_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@RetMsg", ParameterDirection.Output, SqlDbType.VarChar, 0, "");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_HHT_DBProc_SykPickingCancel_NOPickingList", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                return result;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #endregion

        #region"EDI"

        #region"Delivery Order (Edit EDI data)"

        #region"Search"

        /// <summary>
        /// Search the first step Get Main DataSource
        /// 
        /// Author:Michael
        /// Create Date:2008-11-14
        /// </summary>
        /// <param name="str_FB_NO">FB_NO</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_EDI_Edit_SykData_GetData(string str_FB_NO)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[1];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_EDI_Edit_SykData_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_EDI_Edit_SykData_GetData Error" + err.Message, "G_F_EDI_Edit_SykData_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        /// <summary>
        /// Search the second setp Insert data
        /// 
        /// author:Michael
        /// create date:2008-11-14
        /// </summary>
        /// <param name="str_FB_NO">FB_NO</param>
        /// <param name="str_PC_NM">PC_Name</param>
        /// <returns></returns>
        public static int G_F_EDI_Edit_SykData_Sub_Insert(string str_FB_NO, string str_PC_NM)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_EDI_Edit_SykData_DataInsert", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_EDI_Edit_SykData_Sub_Insert Error" + err.Message, "G_F_EDI_Edit_SykData_Sub_Insert");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                result = -11;
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        /// <summary>
        /// Search the three step Get Grid Data
        /// 
        /// Author:Michael
        /// Create Date:2008-11-14
        /// </summary>
        /// <param name="str_PC_NM">PC_Name</param>
        /// <returns></returns>
        public static DataTable G_F_EDI_Edit_SykData_Sub_GetDate(string str_PC_NM)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {

                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_EDI_Edit_SykData_SUB_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_EDI_Edit_SykData_Sub_GetDate Error" + err.Message, "G_F_EDI_Edit_SykData_Sub_GetDate");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion

        #region"Update"

        /// <summary>
        /// Update Detail Data
        /// 
        /// 
        /// Author:Michael
        /// Create Date:2008-11-15
        /// </summary>
        /// <param name="str_BD_ID">BD_ID</param>
        /// <param name="str_Meis_KB">Meis_KB</param>
        /// <param name="str_Shoh_CD">Product Code</param>
        /// <param name="str_Shoh_NM">Product Name</param>
        /// <param name="str_JAN_CD">Jan Code</param>
        /// <param name="str_Yote_QT">EDI Actual Quantity</param>
        /// <param name="str_jisk_QT">Print Quantity</param>
        /// <param name="str_Price">Price Name</param>
        /// <param name="str_PC_NM">PC Name</param>
        /// <returns>int</returns>
        public static int G_F_EDI_Edit_SykData_Sub_Update(string str_BD_ID, string str_Meis_KB, string str_Shoh_CD, string str_Shoh_NM,
                                                          string str_JAN_CD, string str_Yote_QT, string str_jisk_QT, string str_Price, string str_PC_NM)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[10];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@BD_ID", ParameterDirection.Input, SqlDbType.Int, 0, str_BD_ID);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Meis_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Meis_KB);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_NM);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@JAN_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_JAN_CD);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Yote_QT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Yote_QT);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@jisk_QT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_jisk_QT);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Price", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Price);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_EDI_Edit_SykData_SUB_DataUpdate", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_EDI_Edit_SykData_Sub_Update Error" + err.Message, "G_F_EDI_Edit_SykData_Sub_Update");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        /// <summary>
        /// Update Header Data To DB
        /// 
        /// Author:Michael
        /// Create Date :2008-11-15
        /// </summary>
        /// <param name="sykData">Delivery Order (Edit EDI data) Data Entry </param>
        /// <returns>Int</returns>
        public static int G_F_EDI_Edit_SykData_Update(G_CommonClassDBEntry.EDISykData sykData)
        {
            int result = -11;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[28];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@HD_ID", ParameterDirection.Input, SqlDbType.Int, 0, sykData.str_HD_ID);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, sykData.str_FB_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Tori_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Attribute_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Attribute_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nouk_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Nouk_DT);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Unso_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Denp_Biko", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Denp_Biko);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jytu_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Jytu_DT);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_CD);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_Zip_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_Zip_NO);

                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_AD_01", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_AD_01);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_AD_02", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_AD_02);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_AD_03", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_AD_03);
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_NM_01", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_NM_01);
                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_NM_02", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_NM_02);

                sqlPara[15] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Todo_Tel_No", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Todo_Tel_No);
                sqlPara[16] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_CD);
                sqlPara[17] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_Zip_No", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_Zip_No);
                sqlPara[18] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_AD_01", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_AD_01);
                sqlPara[19] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_AD_02", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_AD_02);

                sqlPara[20] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_AD_03", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_AD_03);
                sqlPara[21] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_NM_01", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_NM_01);
                sqlPara[22] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_NM_02", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_NM_02);
                sqlPara[23] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Toku_Tel_No", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Toku_Tel_No);
                sqlPara[24] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Konp_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Konp_KB);

                sqlPara[25] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Instructions", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_Instructions);
                sqlPara[26] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, sykData.str_PC_NM);
                sqlPara[27] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_EDI_Edit_SykData_DataUpdate", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_EDI_Edit_SykData_Update" + err.Message, "G_F_EDI_Edit_SykData_Update");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);

                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #endregion

        #region "Actual Delivery Export"

        #region "Select"

        /// <summary>
        /// Get data 
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Unso_KB">Exprot method</param>
        /// <param name="str_Date1">start date</param>
        /// <param name="str_Date2">end date</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_EDI_Result_FowardData_GetData(string str_Tori_CD, string str_Unso_KB, string str_Date1, string str_Date2)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[4];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Unso_KB);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Date1", ParameterDirection.Input, SqlDbType.DateTime, 0, str_Date1);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Date2", ParameterDirection.Input, SqlDbType.DateTime, 0, str_Date2);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_EDI_Result_FowardData_SUB_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_EDI_Result_FowardData_GetData Error" + err.Message, "G_F_EDI_Result_FowardData_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion

        #region "Update"

        //public static int G_F_EDI_Result_FowardData_

        #endregion

        #region "Export"

        public static DataSet G_F_EDI_Result_FowardData_Output_UpdateFowardData_Yamat(string strToriCD, string strUnsoKB, string strSykDT, string strOutCNT, string strFilePath)
        {
            SqlConnection connect = null;
            DataSet ds = null;

            try
            {
                //DB接続
                if (!G_CommonClassDB.G_DB_Connect(out connect))
                {
                    //エラーメッセージ表示
                    P_MessageBox_Connection();
                    return ds;
                }

                SqlCommand sqlCmd = connect.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[7];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, strToriCD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, strUnsoKB);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Syk_DT", ParameterDirection.Input, SqlDbType.SmallDateTime, 0, strSykDT);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Out_CNT", ParameterDirection.Input, SqlDbType.Int, 0, strOutCNT);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FilePath", ParameterDirection.Input, SqlDbType.VarChar, 0, strFilePath);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                sqlCmd.CommandTimeout = 1000;

                G_CommonClassDB.G_DB_ExecStoredProc(connect, sqlCmd, "USP_PC_F_EDI_Result_FowardData_DataUpdate", sqlPara, out ds);

                return ds;
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return ds;
            }
            finally
            {
                if (connect != null)
                {
                    //DB開放
                    if (!G_CommonClassDB.G_DB_Dispose(connect))
                    {
                        //エラーメッセージ表示
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }


        /// <summary>
        /// Export to Text
        /// </summary>
        /// <param name="strToriCD"></param>
        /// <param name="strUnsoKB"></param>
        /// <param name="strSykDT"></param>
        /// <param name="strOutCNT"></param>
        /// <param name="strFilePath"></param>
        /// <returns></returns>
        public static int G_F_EDI_Result_FowardData_Output_UpdateFowardData_Text(string strToriCD, string strUnsoKB, string strSykDT, string strOutCNT, string strFilePath)
        {

            int result = -11;
            SqlConnection connect = null;

            try
            {
                //DB接続
                if (!G_CommonClassDB.G_DB_Connect(out connect))
                {
                    //エラーメッセージ表示
                    P_MessageBox_Connection();
                    return result;
                }

                SqlCommand sqlCmd = connect.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[7];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, strToriCD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, strUnsoKB);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Syk_DT", ParameterDirection.Input, SqlDbType.SmallDateTime, 0, strSykDT);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Out_CNT", ParameterDirection.Input, SqlDbType.Int, 0, strOutCNT);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FilePath", ParameterDirection.Input, SqlDbType.VarChar, 0, strFilePath);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutpara;

                //ストアド実行
                G_CommonClassDB.G_DB_ExecStoredProc(connect, sqlCmd, "USP_PC_F_EDI_Result_FowardData_DataUpdate", sqlPara, out sqloutpara);

                //リターン判定
                result = int.Parse(sqloutpara[0].Value.ToString());
                return result;
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (connect != null)
                {
                    //DB開放
                    if (!G_CommonClassDB.G_DB_Dispose(connect))
                    {
                        //エラーメッセージ表示
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }
        #endregion

        #endregion

        #region "Actual Delivery"

        #region "Export"


        /// <summary>
        /// Export File
        /// 
        /// Author:Michael
        /// Create Date:2008-12-03
        /// </summary>
        /// <param name="str_Tori_CD">Custoemr Code</param>
        /// <param name="str_Syk_DT">Delivery Date</param>
        /// <param name="str_Syk_CNT">Export Number</param>
        /// <param name="str_FilePath">File Path</param>
        /// <returns>Int</returns>
        public static int G_F_EDI_Result_SykData_Output_File(string str_Tori_CD, string str_Syk_DT, string str_Syk_CNT, string str_FilePath)
        {
            int result = -11;

            SqlConnection connect = null;
            try
            {
                //DB接続
                if (!G_CommonClassDB.G_DB_Connect(out connect))
                {

                    P_MessageBox_Connection();
                    return result;
                }

                SqlCommand sqlCmd = connect.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[7];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Syk_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Syk_DT);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Syk_CNT", ParameterDirection.Input, SqlDbType.Int, 0, str_Syk_CNT);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FilePath", ParameterDirection.Input, SqlDbType.VarChar, 0, str_FilePath);
                //////////////////////////// 2008.04.30 Araki Add Start ////////////////////////////
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_WorkCD.ToString());
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                //////////////////////////// 2008.04.30 Araki Add End //////////////////////////////
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqlOutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(connect, sqlCmd, "USP_PC_F_EDI_Result_SykEDIData_DataInsert", sqlPara, out sqlOutPara);

                result = 0;//int.Parse(sqlOutPara[0].Value.ToString());
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (connect != null)
                {
                    //DB�解放

                    if (!G_CommonClassDB.G_DB_Dispose(connect))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #region "Select"

        /// <summary>
        /// Get Data
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Date1">Start Delivery Date</param>
        /// <param name="str_Date2">End Delivery Date</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_EDI_Result_SykData_GetData(string str_Tori_CD, string str_Date1, string str_Date2)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Date1", ParameterDirection.Input, SqlDbType.DateTime, 0, str_Date1);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Date2", ParameterDirection.Input, SqlDbType.DateTime, 0, str_Date2);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_EDI_Result_SykData_SUB_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_EDI_Result_SykData_GetData Error" + err.Message, "G_F_EDI_Result_SykData_GetData");
                return dt;
            }

            return dt;
        }

        #endregion

        #endregion

        #region "Actual Issuing Records"

        #region"Search"

        public static DataTable G_F_EDI_SYK_Result_GetData(string str_Mode, string str_DO_NO, string str_Cust_NO, string str_Jyht_NO, string str_Jisk_DT, string str_SortMode, string str_Souk_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[8];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@DO_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_DO_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_NO);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyht_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyht_NO);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jisk_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jisk_DT);
                //add by Michael Date:2008-12-23
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SortMode", ParameterDirection.Input, SqlDbType.Int, 0, str_SortMode);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Souk_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_EDI_Result_SykData_FE_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_EDI_SYK_Result_GetData Error", "G_F_EDI_SYK_Result_GetData");
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }


        #endregion

        #region"Update"

        /// <summary>
        /// Insert Data
        /// 
        /// Author:Michael
        /// Create Data:2008-12-10
        /// </summary>
        /// <param name="str_Mode">Mode</param>
        /// <param name="str_Cust_NO">Invoice No</param>
        /// <param name="str_Jyht_No">So</param>
        /// <param name="str_Syk_DT">Actual Delivery Date</param>
        /// <param name="str_Status">Status</param>
        /// <param name="str_Work_CD">Work Code</param>
        /// <param name="str_Work_NM">Work Name</param>
        /// <param name="str_Jisk_DT">Delivery Date</param>
        /// <returns></returns>
        public static int G_F_EDI_SYK_Result_FE_Insert(string str_Mode, string str_Cust_NO, string str_Jyht_No, string str_Syk_DT, string str_Status, string str_Work_CD, string str_Work_NM, string str_Jisk_DT, string str_Tori_CD, string str_FB_NO)
        {
            int result = -1;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[11];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyht_No", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyht_No);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Syk_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Syk_DT);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Status);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Work_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Work_NM);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jisk_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jisk_DT);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_FB_NO);
                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_EDI_Result_SykData_FE_DataInsert", sqlPara, out sqloutPara);

                result = int.Parse(sqloutPara[0].Value.ToString());
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_EDI_SYK_Result_FE_Insert" + err.Message, "G_F_EDI_SYK_Result_FE_Insert");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #endregion

        #region "Serial Issuing Action"

        #region"Search"

        /// <summary>
        /// Get Serial Issuing Actual Data
        /// </summary>
        /// <param name="str_start_DT"></param>
        /// <param name="str_end_DT"></param>
        /// <param name="str_Cust_NO"></param>
        /// <returns></returns>
        public static DataTable G_F_Report_SerialIssuingActual_Getdata(string str_start_DT, string str_end_DT, string str_Cust_NO)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out  sqlConnection))
                {
                    P_MessageBox_Connection();
                    return null;
                }
                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[4];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@start_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_start_DT);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@end_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_end_DT);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_NO);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);

                if ((G_CommonDefine.G_str_Customer_CD == "FDTH") || (G_CommonDefine.G_str_Customer_CD == "EIC"))
                {
                    sqlPara = new SqlParameter[5];

                    sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@start_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_start_DT);
                    sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@end_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_end_DT);
                    sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_NO);
                    sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                    sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_CD);
                    G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reprot_T_LotIssuingActual_DataSelect", sqlPara, out ds);
                }
                else
                    G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reprot_T_SerialIssuingActual_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion

        #endregion

        #region"All Serial"

        #region"Select"

        public static DataTable G_F_Report_SerialExport_GetData(string str_Cust_CD, string str_PO, string str_ST_DT, string str_ED_DT, string str_Shoh_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[5];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ST_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_ST_DT);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ED_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_ED_DT);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Report_T_Serial_DataSelect_ALL", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }


            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        public static DataTable G_F_Report_SerialExport_GetPrintData(string str_Cust_CD, string str_PO, string str_ST_DT, string str_ED_DT, string str_Shoh_CD, string str_Serial_No)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[6];
                if ((G_CommonDefine.G_str_Customer_CD == "FDTH") || (G_CommonDefine.G_str_Customer_CD == "EIC"))
                {
                    sqlPara = new SqlParameter[7];
                    sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_CD);
                    sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PO);
                    sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ST_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_ST_DT);
                    sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ED_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_ED_DT);
                    sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                    sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@LOT_No", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Serial_No);
                    sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_CD);
                    G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Report_T_ALLLOT_DataSelect", sqlPara, out ds);
                }
                else
                {
                    sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_CD);
                    sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PO);
                    sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ST_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_ST_DT);
                    sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ED_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_ED_DT);
                    sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                    sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Serial_No", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Serial_No);

                    G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Report_T_SerialExport_DataSelect", sqlPara, out ds);
                }
                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        #endregion

        #endregion

        #region"Actual Receiving Exprot"



        #endregion


        #region"EDI Receiving Data Imput"

        public static void G_F_EDI_Plan_NykData_CaseMarkTempTable_DataDelete()
        {
            string str_Message = string.Empty;
            string str_Caption = string.Empty;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return;
                }

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 50, G_CommonDefine.G_PCNM);

                SqlParameter[] sqlOutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_EDI_BWHCASE_Temp_DataDelete", sqlPara, out sqlOutPara);
            }
            catch (Exception err)
            {

                MessageBox.Show(err.Message);
            }
            finally
            {

                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #endregion

        #region"Inquiry"

        #region"Insufficient Stock INQ"

        #region "Search"

        /// <summary>
        /// Search the first step Insert Data
        /// </summary>
        /// <param name="str_Mode">Mode</param>
        /// <param name="str_Shoh_CD">Product Code</param>
        /// <param name="str_PC_NM">PC Name</param>
        /// <returns>Int</returns>
        public static int G_F_Reference_LackInfo_ADJ_Insert(string str_Mode, string str_Shoh_CD, string str_PC_NM, string str_SECTION_CODE)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[4];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_LackInfo_ADJ_SUB_List_DataInsert", sqlPara, out sqloutPara);

                result = 0;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_LackInfo_ADJ_Insert" + err.Message, "G_F_Reference_LackInfo_ADJ_Insert");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        /// <summary>
        /// Search the second get data 
        /// </summary>
        /// <param name="str_PC_NM">PC Name</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Reference_LackInfo_ADJ_GetData(string str_PC_NM)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_LackInfo_ADJ_SUB_List_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_LackInfo_ADJ_GetData" + err.Message, "G_F_Reference_LackInfo_ADJ_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        /// <summary>
        /// Search ISSUS Data
        /// 
        /// Author:Michael
        /// Create Date:2008-11-19
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Nins_CD">Shipper Code</param>
        /// <param name="str_Shoh_CD">Product Code</param>
        /// <param name="str_Jyot_KB">Status</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Reference_LackInfo_ADJ_GetData_Syk(string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_Jyot_KB)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[4];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyot_KB);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_LackInfo_ADJ_SUB_Syk_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_LackInfo_ADJ_GetData_Syk" + err.Message, "G_F_Reference_LackInfo_ADJ_GetData_Syk");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        /// <summary>
        /// Search ISSUS Data
        /// 
        /// Author:Michael
        /// Create Date:2008-11-19
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Nins_CD">Shipper Code</param>
        /// <param name="str_Shoh_CD">Product Code</param>
        /// <param name="str_Jyot_KB">Status</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Reference_LackInfo_ADJ_GetData_HojyuNyk(string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_Jyot_KB)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[4];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyot_KB);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_LackInfo_SUB_HojyuNyk_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_LackInfo_ADJ_GetData_Syk" + err.Message, "G_F_Reference_LackInfo_ADJ_GetData_Syk");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        #endregion

        #region"Print"

        /// <summary>
        /// Get Print Data LackInfo
        /// </summary>
        /// <param name="str_Shoh_CD">Product Code</param>
        /// <param name="str_PC_NM">PC Name</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Reference_LackInfo_ADJ_Print_LackList(string str_Shoh_CD, string str_PC_NM)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_R_LackList_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonDefine.G_Message_Error;
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_LackInfo_ADJ_Print_LackList Error" + err.Message, "G_F_Reference_LackInfo_ADJ_Print_LackList");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {

                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion

        #endregion

        #region "Receive Issue Information "

        #region "Search"

        /// <summary>
        /// Search Receive Or Issue Information
        /// </summary>
        /// <param name="str_Mode">Mode</param>
        /// <param name="str_Search_ID">Search Condition Value</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Reference_NsykInfo_GetData(string str_Mode, string str_Search_ID, string str_SECTION_CODE)
        {

            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[3];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_ID", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_ID);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_NsykInfo_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_NsykInfo_GetData Error" + err.Message, "G_F_Reference_NsykInfo_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {

                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        /// <summary>
        /// Get Data for BD DataGrid
        /// </summary>
        /// <param name="str_Search_Mode"></param>
        /// <param name="str_Sort_Mode"></param>
        /// <param name="str_Search_CD"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_NsykInfo_GetData_BD(string str_Search_Mode, string str_Sort_Mode, string str_Search_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[3];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sort_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Sort_Mode);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_NsykInfo_SUB_Detail_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_NsykInfo_GetData_BD Error", "G_F_Reference_NsykInfo_GetData_BD");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {

                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        /// <summary>
        /// Get TL DataTable
        /// </summary>
        /// <param name="str_Search_Mode"></param>
        /// <param name="str_Sort_Mode"></param>
        /// <param name="str_Search_CD"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_NsykInfo_GetData_TL(string str_Search_Mode, string str_Sort_Mode, string str_Search_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[3];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sort_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Sort_Mode);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_NsykInfo_SUB_Detail_TL_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_NsykInfo_GetData_TL Error", "G_F_Reference_NsykInfo_GetData_TL");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        /// <summary>
        /// Get Lot DataTable
        /// </summary>
        /// <param name="str_Search_Mode"></param>
        /// <param name="str_Sort_Mode"></param>
        /// <param name="str_Search_CD"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_NsykInfo_GetData_Lot(string str_Search_Mode, string str_Sort_Mode, string str_Search_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[3];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sort_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Sort_Mode);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_NsykInfo_SUB_Detail_Lot_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_NsykInfo_GetData_Lot Error", "G_F_Reference_NsykInfo_GetData_Lot");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        /// <summary>
        /// Packing DataTable
        /// </summary>
        /// <param name="str_Ship_NO"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_NsykInfo_GetData_Packing(string str_Ship_NO)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ship_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Ship_NO);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_NsykInfo_SUB_Packing_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_NsykInfo_GetData_Packing Error", "G_F_Reference_NsykInfo_GetData_Packing");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        /// <summary>
        /// Get Status DataTable
        /// </summary>
        /// <param name="str_Search_Mode"></param>
        /// <param name="str_Search_CD"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_NsykInfo_GetData_Status(string str_Search_Mode, string str_Search_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[2];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_NsykInfo_SUB_Status_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_NsykInfo_GetData_Status Error", "G_F_Reference_NsykInfo_GetData_Status");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        public static DataTable G_F_Reference_NsykInfo_GetPrintData(string str_Mode, string str_HD_Mode, string str_Search_ID)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@HD_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_HD_Mode);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_ID", ParameterDirection.Input, SqlDbType.VarChar, 0,str_Search_ID);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_R_NsykInfoList_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

                return dt;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static void G_F_Reference_NsykInfo_Print(DataTable dt, DataTable dt_BD, DataTable dt_TL, DataTable dt_Lot, DataTable dt_Status, DataTable dt_Packing,string str_Mod_Msg)
        {
            string str_Caption = string.Empty;
            string str_Message = string.Empty;
            try
            {
                ExcelAccess xlReport = new ExcelAccess();

                string strPath = Application.StartupPath + @"\Report";
                string strExcelTemplateFile = System.IO.Path.GetFullPath(strPath + @"\R_NsykInfoList.xlt");

                if (!System.IO.File.Exists(strExcelTemplateFile))
                {
                    str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Excel_Template_NoExists);
                    str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                    MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                xlReport.Open(strExcelTemplateFile);
                xlReport.IsVisibledExcel = true;

                int RowIndex = 0;
                //int PageTotalRowCount = 42;
                Microsoft.Office.Interop.Excel.Range range;
                Microsoft.Office.Interop.Excel.Range subRange;
                Object oMissing = System.Reflection.Missing.Value;

                //Total Print
                //C列
                DataRow MRow = dt.Rows[0];


                xlReport.SetCellText(RowIndex + 3, "C", MRow["Tori_CD"].ToString());
                xlReport.SetCellText(RowIndex + 4, "C", MRow["Ship_No"].ToString());
               
                xlReport.SetCellText(RowIndex + 5, "C", MRow["Todo_CD"].ToString());
                xlReport.SetCellText(RowIndex + 6, "C", MRow["TdZip_NO"].ToString());
                xlReport.SetCellText(RowIndex + 7, "C", MRow["Toku_CD"].ToString());
                xlReport.SetCellText(RowIndex + 8, "C", MRow["Toku_Zip_No"].ToString());
                xlReport.SetCellText(RowIndex + 9, "C", MRow["Siji_DT"].ToString());
                xlReport.SetCellText(RowIndex + 10, "C", MRow["UnsoSend_FG"].ToString() + " " + MRow["UnsoSend_DT"].ToString());
                xlReport.SetCellText(RowIndex + 11, "C", MRow["JiskSend_FG"].ToString() + " " + MRow["JiskSend_DT"].ToString());
                xlReport.SetCellText(RowIndex + 12,"C",MRow["Bik_01_TXT"].ToString());
                range = xlReport.GetRange(RowIndex + 12,"C",RowIndex + 12,"F");
                range.Merge(oMissing);
                xlReport.SetCellText(RowIndex + 13, "C", MRow["Bik_02_TXT"].ToString());
                range = xlReport.GetRange(RowIndex + 13, "C", RowIndex + 13, "F");
                range.Merge(oMissing);

                //E列
                xlReport.SetCellText(RowIndex + 3,"E",MRow["FB_NO"].ToString());
                xlReport.SetCellText(RowIndex + 4,"E",MRow["Cust_No"].ToString());
                xlReport.SetCellText(RowIndex + 5, "E", MRow["TdTel_NO"].ToString());

                range = xlReport.GetRange(RowIndex + 6, "E", RowIndex + 6, "K");
                range.Merge(oMissing);
                xlReport.SetCellText(RowIndex + 6, "E", MRow["Tdad_01_NM"].ToString() + MRow["Tdad_02_NM"].ToString() + MRow["Tdad_03_NM"].ToString());
        
                xlReport.SetCellText(RowIndex + 7, "E", MRow["Toku_Tel_No"].ToString());

                range = xlReport.GetRange(RowIndex + 8, "E", RowIndex + 8, "K");
                range.Merge(oMissing);
                xlReport.SetCellText(RowIndex + 8, "E", MRow["Toku_AD_01"].ToString() + MRow["Toku_AD_02"].ToString() + MRow["Toku_AD_03"].ToString());
         
  
                xlReport.SetCellText(RowIndex + 9, "E", MRow["Jisk_DT"].ToString());
                xlReport.SetCellText(RowIndex + 10, "E", MRow["Unso_CD"].ToString() + " " + MRow["Unso_NM"].ToString());
                xlReport.SetCellText(RowIndex + 11, "E", MRow["Time_NM"].ToString());

                //G列
                xlReport.SetCellText(RowIndex + 3, "G", MRow["NSk_NM"].ToString());
                xlReport.SetCellText(RowIndex + 4,"G",MRow["Ktyu_NO"].ToString());
                range = xlReport.GetRange(RowIndex + 5, "G", RowIndex + 5, "K");
                range.Merge(oMissing);
                xlReport.SetCellText(RowIndex + 5, "G", MRow["Tdnm_01_NM"].ToString() + MRow["Tdnm_02_NM"].ToString());
     

                xlReport.SetCellText(RowIndex + 7, "G", MRow["Toku_NM_01"].ToString() + MRow["Toku_NM_02"].ToString());
                range = xlReport.GetRange(RowIndex + 7, "G", RowIndex + 7, "K");
                range.Merge(oMissing);
       
                xlReport.SetCellText(RowIndex + 9, "G", MRow["Jytu_DT"].ToString());
                xlReport.SetCellText(RowIndex + 10, "G", MRow["Inji_QT"].ToString());
                xlReport.SetCellText(RowIndex + 11, "G", MRow["Nsai_NM"].ToString());


                //H列
                xlReport.SetCellText(RowIndex + 12,"H",MRow["Tant_NM"].ToString());
                xlReport.SetCellText(RowIndex + 13,"H",MRow["Bik_03_TXT"].ToString());
                range = xlReport.GetRange(RowIndex + 13,"H",RowIndex + 13,"K");
                range.Merge(oMissing);

                //I列
                xlReport.SetCellText(RowIndex + 3, "I", MRow["Data_NM"].ToString());
                xlReport.SetCellText(RowIndex + 4, "I", MRow["Jyht_NO"].ToString());
            

                xlReport.SetCellText(RowIndex + 9, "I", MRow["Uria_DT"].ToString());
                xlReport.SetCellText(RowIndex + 10, "I", MRow["Hrai_NM"].ToString());
                xlReport.SetCellText(RowIndex + 11, "I", MRow["Edom_NM"].ToString());

                //K列
                xlReport.SetCellText(RowIndex + 1, "K", str_Mod_Msg);
                range = xlReport.GetRange(RowIndex + 1, "K", RowIndex + 2, "K");
                range.Merge(oMissing);
                xlReport.SetCellText(RowIndex + 3, "K", MRow["Pend_NM"].ToString());
                xlReport.SetCellText(RowIndex + 4, "K", MRow["Okri_No"].ToString());
                xlReport.SetCellText(RowIndex + 9, "K", MRow["Nouk_DT"].ToString());
                xlReport.SetCellText(RowIndex + 10, "K", MRow["Hait_QT"].ToString());
                xlReport.SetCellText(RowIndex + 11, "K", MRow["Sden_NM"].ToString());

                RowIndex += 14;
                
                DataRow Row = null;

                //Status
                int subIndex = 1;

                if ((dt_Status != null) && (dt_Status.Rows.Count > 0))
                {
                    for (subIndex = 1; subIndex <= dt_Status.Rows.Count; subIndex++)
                    {
                        Row = dt_Status.Rows[subIndex - 1];
                        xlReport.InsertRow(RowIndex + subIndex);
                        range = xlReport.GetRange(RowIndex + subIndex, "A", RowIndex + subIndex, "K");
                        range.Clear();

                        xlReport.SetCellText(RowIndex + subIndex, "B", Row["Status_JP"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "B", RowIndex + subIndex, "C");
                        range.Merge(oMissing);
                        xlReport.SetCellText(RowIndex + subIndex, "D", Row["JISK_DT"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "D", RowIndex + subIndex, "E");
                        range.Merge(oMissing);
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                        xlReport.SetCellText(RowIndex + subIndex, "F", Row["Work_NM"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "F", RowIndex + subIndex, "G");
                        range.Merge(oMissing);
                        xlReport.SetCellText(RowIndex + subIndex, "H", Row["PC_NM"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "H", RowIndex + subIndex, "I");
                        range.Merge(oMissing);
                        xlReport.SetCellText(RowIndex + subIndex, "J", Row["FB_NO"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "J", RowIndex + subIndex, "K");
                        range.Merge(oMissing);
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                    }
                    range = xlReport.GetRange(RowIndex, "B", RowIndex + subIndex - 1, "K");
                    range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideHorizontal].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;

                }

                //移动到Packing Info
                RowIndex = RowIndex + subIndex ;
                subIndex = 1;//调两行
                
                if ((dt_Packing != null) && (dt_Packing.Rows.Count > 0))
                {
                    for (subIndex = 1; subIndex <= dt_Packing.Rows.Count; subIndex++)
                    {
                        Row = dt_Packing.Rows[subIndex - 1];
                        xlReport.InsertRow(RowIndex + subIndex);
                        range = xlReport.GetRange(RowIndex + subIndex, "A", RowIndex + subIndex, "K");
                        range.Clear();

                        xlReport.SetCellText(RowIndex + subIndex, "B", Row["ShipPOS_NO"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "B", RowIndex + subIndex, "C");
                        range.Merge(oMissing);
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        xlReport.SetCellText(RowIndex + subIndex, "D", Row["Keit_NM"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "D", RowIndex + subIndex, "E");
                        range.Merge(oMissing);

                        xlReport.SetCellText(RowIndex + subIndex, "F", Row["Jisk_QT"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "F");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        range = xlReport.GetRange(RowIndex + subIndex, "B", RowIndex + subIndex, "K");
                        range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
                        range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;
                    }

                }
                //移动到BD Info
                RowIndex = RowIndex + subIndex + 1;
                subIndex = 2;//调两行
                int RowCount = 2;

                if ((dt_BD != null) && (dt_BD.Rows.Count > 0))
                {
                    subIndex = 0;

                    for (int i = 0; i < dt_BD.Rows.Count; i++)
                    {
                        Row = dt_BD.Rows[i];

                        //插入两行
                        subIndex = 2 * i + 1;
                        xlReport.InsertRow(RowIndex + subIndex);
                        xlReport.InsertRow(RowIndex + subIndex);
                        range = xlReport.GetRange(RowIndex + subIndex, "A", RowIndex + subIndex + 1, "K");
                        range.Clear();


                        xlReport.SetCellText(RowIndex + subIndex, "B", Row["FB_NO"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "B");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        xlReport.SetCellText(RowIndex + subIndex, "C", Row["FBPOS_NO"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "C");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        xlReport.SetCellText(RowIndex + subIndex, "E", Row["Nins_CD"].ToString());
                        xlReport.SetCellText(RowIndex + subIndex, "F", Row["Meib_TXT"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "F", RowIndex + subIndex, "G");
                        range.Merge(oMissing);
                        xlReport.SetCellText(RowIndex + subIndex, "H", Row["Jyot_NM"].ToString());
                        xlReport.SetCellText(RowIndex + subIndex, "I", Row["Tani_NM"].ToString());
                        xlReport.SetCellText(RowIndex + subIndex, "I", Row["Meis_NM"].ToString());


                        xlReport.SetCellText(RowIndex + subIndex + 1, "B", Row["Body_ST"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex + 1, "B");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        xlReport.SetCellText(RowIndex + subIndex + 1, "C", Row["Shoh_CD"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex + 1, "C", RowIndex + subIndex + 1, "D");
                        range.Merge(oMissing);
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                        xlReport.SetCellText(RowIndex + subIndex + 1, "E", Row["Shoh_NM"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex + 1, "E", RowIndex + subIndex + 1, "H");
                        range.Merge(oMissing);
                        xlReport.SetCellText(RowIndex + subIndex + 1, "I", Row["Yote_QT"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex + 1, "I");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        xlReport.SetCellText(RowIndex + subIndex + 1, "J", Row["Jisk_QT"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex + 1, "J");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        range = xlReport.GetRange(RowIndex + subIndex, "B", RowIndex + subIndex + 1, "K");
                        range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
                        range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;
                    }

                }
                //移动到TL Info
                RowIndex = RowIndex + subIndex + 2 + 1;
                subIndex = 1;//调两行
                if ((dt_TL != null) && (dt_TL.Rows.Count > 0))
                {
                    for (int i = 0; i < dt_TL.Rows.Count; i++)
                    {
                        Row = dt_TL.Rows[i];

                        //插入两行
                        subIndex = 2 * i + 1;
                        xlReport.InsertRow(RowIndex + subIndex);
                        xlReport.InsertRow(RowIndex + subIndex);
                        range = xlReport.GetRange(RowIndex + subIndex, "A", RowIndex + subIndex + 1, "K");
                        range.Clear();

                        xlReport.SetCellText(RowIndex + subIndex, "B", Row["FB_NO"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "B");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        xlReport.SetCellText(RowIndex + subIndex, "C", Row["FBPOS_NO"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "C");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        xlReport.SetCellText(RowIndex + subIndex, "D", Row["SEQ_NO"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "D");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        xlReport.SetCellText(RowIndex + subIndex, "E", Row["Souk_CD"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "E");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                        range.NumberFormat = "@";

                        xlReport.SetCellText(RowIndex + subIndex, "F", Row["Lot_CD"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "F");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        xlReport.SetCellText(RowIndex + subIndex, "G", Row["lbl_No"].ToString());
                        xlReport.SetCellText(RowIndex + subIndex, "H", Row["Work_CD"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "H", RowIndex + subIndex, "I");
                        range.Merge(oMissing);
                        xlReport.SetCellText(RowIndex + subIndex, "J", Row["Nyuk_DT"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "J", RowIndex + subIndex, "K");
                        range.Merge(oMissing);
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        xlReport.SetCellText(RowIndex + subIndex + 1, "B", Row["Pic_No"].ToString());
                        xlReport.SetCellText(RowIndex + subIndex + 1, "C", Row["PicPos_No"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex + 1, "C");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        xlReport.SetCellText(RowIndex + subIndex + 1, "D", Row["Tail_ST"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex + 1, "D");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        string Loca_CD = Row["Loca_CD"].ToString();
                        if (Loca_CD.Length == 11)
                        {
                            Loca_CD = Loca_CD.Substring(0, 3) + "-" + Loca_CD.Substring(3, 3) + "-" + Loca_CD.Substring(6, 2) + "-" + Loca_CD.Substring(8, 1) + "-" + Loca_CD.Substring(9, 2);
                        }

                        xlReport.SetCellText(RowIndex + subIndex + 1, "E", Loca_CD);
                        xlReport.SetCellText(RowIndex + subIndex + 1, "F", Row["SRC_No"].ToString());

                        xlReport.SetCellText(RowIndex + subIndex + 1, "G", Row["Iri_QT"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex + 1, "G");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        xlReport.SetCellText(RowIndex + subIndex + 1, "H", Row["Yote_QT"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex + 1, "H");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        xlReport.SetCellText(RowIndex + subIndex + 1, "I", Row["Jisk_QT"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex + 1, "I");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        xlReport.SetCellText(RowIndex + subIndex + 1, "J", Row["Jisk_DT"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex + 1, "J", RowIndex + subIndex + 1, "K");
                        range.Merge(oMissing);
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        range = xlReport.GetRange(RowIndex + subIndex, "B", RowIndex + subIndex + 1, "K");
                        range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
                        range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;
       
                    }
                    //range = xlReport.GetRange(RowIndex + 1, "A", RowIndex + dt_BD.Rows.Count * 2, "K");
                    //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlInsideHorizontal].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;
                }
       

                //称动到Lot
                RowIndex = RowIndex + subIndex + 2;
                subIndex = 1;//调1行
                if ((dt_Lot != null) && (dt_Lot.Rows.Count > 0))
                {
                    for (subIndex = 1; subIndex <= dt_Lot.Rows.Count; subIndex++)
                    {
                        Row = dt_Lot.Rows[subIndex - 1];
                        xlReport.InsertRow(RowIndex + subIndex);
                        range = xlReport.GetRange(RowIndex + subIndex, "A", RowIndex + subIndex, "K");
                        range.Clear();

                        xlReport.SetCellText(RowIndex + subIndex, "B", Row["Shoh_CD"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "B", RowIndex + subIndex, "C");
                        range.Merge(oMissing);

                        xlReport.SetCellText(RowIndex + subIndex, "D", Row["Shoh_NM"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "D", RowIndex + subIndex, "G");
                        range.Merge(oMissing);
                        xlReport.SetCellText(RowIndex + subIndex, "H", Row["Lot_CD"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "H", RowIndex + subIndex, "I");
                        range.Merge(oMissing);
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                        xlReport.SetCellText(RowIndex + subIndex, "J", Row["Lot_QT"].ToString());
                        range = xlReport.GetRange(RowIndex + subIndex, "J");
                        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                        range = xlReport.GetRange(RowIndex + subIndex, "B", RowIndex + subIndex, "K");
                        range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
                        range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;
       
                    }
                }
               

                //string str_Title = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Please_Set_Dest);
                //string str_InitialDir = @G_CommonClassSystem.G_System_GetDeskTopPath().ToString();
                //SaveFileDialog saveFileDialog = new SaveFileDialog();
                //saveFileDialog.Filter = "(*.xls)|*.xls|(*.*)|*.*";
                //saveFileDialog.FileName = "R_NsykInfoList" + DateTime.Now.ToString("yyyyMMddHHmmss");
                //saveFileDialog.InitialDirectory = str_InitialDir;
                //if (saveFileDialog.ShowDialog() == DialogResult.OK)
                //{
                //    xlReport.SaveAs(saveFileDialog.FileName, true);
                //}
                xlReport.PrintPreview();
                xlReport.Close();

              

            }
            catch (Exception err)
            {
                str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }

        #endregion

        #endregion

        #region "Receve Issue Actual Records"

        #region "Search"

        /// <summary>
        /// Search Nyk (入库)
        /// </summary>
        /// <param name="str_Tab_mode"></param>
        /// <param name="str_Search_Mode"></param>
        /// <param name="str_Search_CD"></param>
        /// <param name="str_Datetype"></param>
        /// <param name="str_Target_DT"></param>
        /// <param name="str_Attribute_CD"></param>
        /// <param name="str_Status"></param>
        /// <param name="str_Sort_KB"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_NsykJisseki_GetData_Nyk(string str_Tab_mode, string str_Search_Mode, string str_Search_CD,
                                                                      string str_Datetype, string str_Target_DT, string str_Attribute_CD,
                                                                      string str_Status, string str_Sort_KB, string str_SECTION_CODE)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = new SqlConnection();
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[9];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tab_mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Tab_mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Datetype", ParameterDirection.Input, SqlDbType.Int, 0, str_Datetype);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Target_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Target_DT);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Attribute_CD", ParameterDirection.Input, SqlDbType.Int, 0, str_Attribute_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Status);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sort_KB", ParameterDirection.Input, SqlDbType.Int, 0, str_Sort_KB);
                //ADD BY Michael Date:2009-01-14
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_NsykJisseki_SUB_Nyk_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_NsykJisseki_GetData_Nyk Error" + err.Message, "G_F_Reference_NsykJisseki_GetData_Nyk");
                MessageBox.Show("G_F_Reference_NsykJisseki_GetData_Nyk:" + err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        /// <summary>
        /// Search HojyuNyk 入库补充
        /// </summary>
        /// <param name="str_Tab_mode"></param>
        /// <param name="str_Search_Mode"></param>
        /// <param name="str_Search_CD"></param>
        /// <param name="str_Datetype"></param>
        /// <param name="str_Target_DT"></param>
        /// <param name="str_Attribute_CD"></param>
        /// <param name="str_Status"></param>
        /// <param name="str_Sort_KB"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_NsykJisseki_GetData_HojyuNyk(string str_Tab_mode, string str_Search_Mode, string str_Search_CD,
                                                                      string str_Datetype, string str_Target_DT, string str_Attribute_CD,
                                                                      string str_Status, string str_Sort_KB, string str_SECTION_CODE)
        {

            DataTable dt = null;

            SqlConnection sqlConnection = new SqlConnection();
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[9];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tab_mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Tab_mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Datetype", ParameterDirection.Input, SqlDbType.Int, 0, str_Datetype);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Target_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Target_DT);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Attribute_CD", ParameterDirection.Input, SqlDbType.Int, 0, str_Attribute_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Status);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sort_KB", ParameterDirection.Input, SqlDbType.Int, 0, str_Sort_KB);

                //ADD BY Michael Date:2009-01-14
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_NsykJisseki_SUB_HojyuNyk_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_NsykJisseki_GetData_HojyuNyk Error" + err.Message, "G_F_Reference_NsykJisseki_GetData_HojyuNyk");
                MessageBox.Show("G_F_Reference_NsykJisseki_GetData_HojyuNyk:" + err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }


        /// <summary>
        /// Search HojyuSyk 出库补充
        /// </summary>
        /// <param name="str_Tab_mode"></param>
        /// <param name="str_Search_Mode"></param>
        /// <param name="str_Search_CD"></param>
        /// <param name="str_Datetype"></param>
        /// <param name="str_Target_DT"></param>
        /// <param name="str_Attribute_CD"></param>
        /// <param name="str_Status"></param>
        /// <param name="str_Sort_KB"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_NsykJisseki_GetData_HojyuSyk(string str_Tab_mode, string str_Search_Mode, string str_Search_CD,
                                                              string str_Datetype, string str_Target_DT, string str_Attribute_CD,
                                                              string str_Status, string str_Sort_KB, string str_SECTION_CODE)
        {

            DataTable dt = null;

            SqlConnection sqlConnection = new SqlConnection();
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[9];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tab_mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Tab_mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Datetype", ParameterDirection.Input, SqlDbType.Int, 0, str_Datetype);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Target_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Target_DT);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Attribute_CD", ParameterDirection.Input, SqlDbType.Int, 0, str_Attribute_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Status);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sort_KB", ParameterDirection.Input, SqlDbType.Int, 0, str_Sort_KB);

                //ADD BY Michael Date:2009-01-14
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_NsykJisseki_SUB_HojyuSyk_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_NsykJisseki_GetData_HojyuSyk Error" + err.Message, "G_F_Reference_NsykJisseki_GetData_HojyuSyk");
                MessageBox.Show("G_F_Reference_NsykJisseki_GetData_HojyuSyk:" + err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        /// <summary>
        /// Search Syk 出库
        /// </summary>
        /// <param name="str_Tab_mode"></param>
        /// <param name="str_Search_Mode"></param>
        /// <param name="str_Search_CD"></param>
        /// <param name="str_Datetype"></param>
        /// <param name="str_Target_DT"></param>
        /// <param name="str_Attribute_CD"></param>
        /// <param name="str_Status"></param>
        /// <param name="str_Unso_CD"></param>
        /// <param name="str_Sort_KB"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_NsykJisseki_GetData_Syk(string str_Tab_mode, string str_Search_Mode, string str_Search_CD,
                                                              string str_Datetype, string str_Target_DT, string str_Attribute_CD,
                                                              string str_Status, string str_Unso_CD, string str_Sort_KB, string str_SECTION_CODE)
        {

            DataTable dt = null;

            SqlConnection sqlConnection = new SqlConnection();
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[10];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tab_mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Tab_mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Datetype", ParameterDirection.Input, SqlDbType.Int, 0, str_Datetype);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Target_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Target_DT);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Attribute_CD", ParameterDirection.Input, SqlDbType.Int, 0, str_Attribute_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Status);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Unso_CD);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sort_KB", ParameterDirection.Input, SqlDbType.Int, 0, str_Sort_KB);

                //ADD BY Michael Date:2009-01-14
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_NsykJisseki_SUB_Syk_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_NsykJisseki_GetData_Syk Error" + err.Message, "G_F_Reference_NsykJisseki_GetData_Syk");
                MessageBox.Show("G_F_Reference_NsykJisseki_GetData_Syk:" + err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }


        /// <summary>
        /// Search Picking 提货
        /// </summary>
        /// <param name="str_Tab_mode"></param>
        /// <param name="str_Search_Mode"></param>
        /// <param name="str_Search_CD"></param>
        /// <param name="str_Datetype"></param>
        /// <param name="str_Target_DT"></param>
        /// <param name="str_Attribute_CD"></param>
        /// <param name="str_Status"></param>
        /// <param name="str_Sort_KB"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_NsykJisseki_GetData_Picking(string str_Tab_mode, string str_Search_Mode, string str_Search_CD,
                                                              string str_Datetype, string str_Target_DT, string str_Attribute_CD,
                                                              string str_Status, string str_Sort_KB, string str_SECTION_CODE)
        {

            DataTable dt = null;

            SqlConnection sqlConnection = new SqlConnection();
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[9];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tab_mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Tab_mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Datetype", ParameterDirection.Input, SqlDbType.Int, 0, str_Datetype);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Target_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Target_DT);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Attribute_CD", ParameterDirection.Input, SqlDbType.Int, 0, str_Attribute_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Status);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sort_KB", ParameterDirection.Input, SqlDbType.Int, 0, str_Sort_KB);

                //ADD BY Michael Date:2009-01-14
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_NsykJisseki_SUB_Picking_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_NsykJisseki_GetData_Picking Error" + err.Message, "G_F_Reference_NsykJisseki_GetData_Picking");
                MessageBox.Show("G_F_Reference_NsykJisseki_GetData_Picking:" + err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }


        /// <summary>
        /// Search Packing 包装
        /// </summary>
        /// <param name="str_Tab_mode"></param>
        /// <param name="str_Search_Mode"></param>
        /// <param name="str_Search_CD"></param>
        /// <param name="str_Datetype"></param>
        /// <param name="str_Target_DT"></param>
        /// <param name="str_Attribute_CD"></param>
        /// <param name="str_Status"></param>
        /// <param name="str_Unso_CD"></param>
        /// <param name="str_Sort_KB"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_NsykJisseki_GetData_Packing(string str_Tab_mode, string str_Search_Mode, string str_Search_CD,
                                                              string str_Datetype, string str_Target_DT, string str_Attribute_CD,
                                                              string str_Unso_CD, string str_Sort_KB, string str_SECTION_CODE)
        {

            DataTable dt = null;

            SqlConnection sqlConnection = new SqlConnection();
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[9];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tab_mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Tab_mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Datetype", ParameterDirection.Input, SqlDbType.Int, 0, str_Datetype);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Target_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Target_DT);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Attribute_CD", ParameterDirection.Input, SqlDbType.Int, 0, str_Attribute_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Unso_CD);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sort_KB", ParameterDirection.Input, SqlDbType.Int, 0, str_Sort_KB);

                //ADD BY Michael Date:2009-01-14
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_NsykJisseki_SUB_Packing_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_NsykJisseki_GetData_Packing Error" + err.Message, "G_F_Reference_NsykJisseki_GetData_Packing");
                MessageBox.Show("G_F_Reference_NsykJisseki_GetData_Packing:" + err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }


        public static DataTable G_F_Reference_NsykJisseki_GetData_NykPOBAL(string str_Search_Mode, string str_Search_CD, string str_Datetype, string str_Target_DT, string str_Sort_KB, string str_SECTION_CODE, string str_Tori_CD, string str_Group_CD, string str_Status_KB)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[9];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Datetype", ParameterDirection.Input, SqlDbType.Int, 0, str_Datetype);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Target_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Target_DT);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sort_KB", ParameterDirection.Input, SqlDbType.Int, 0, str_Sort_KB);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Group_CD);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status_KB", ParameterDirection.Input, SqlDbType.Int, 0, str_Status_KB);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_NsykJisseki_SUB_POBAL_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }


        public static DataTable G_F_Reference_NsykJisseki_GetData_Lot(string str_Tab_mode, string str_Search_Mode, string str_Search_CD,
                                                                      string str_Datetype, string str_Target_DT, string str_Attribute_CD,
                                                                      string str_Status, string str_Sort_KB, string str_SECTION_CODE)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[9];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tab_mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Tab_mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Datetype", ParameterDirection.Input, SqlDbType.Int, 0, str_Datetype);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Target_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Target_DT);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Attribute_CD", ParameterDirection.Input, SqlDbType.Int, 0, str_Attribute_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Status", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Status);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sort_KB", ParameterDirection.Input, SqlDbType.Int, 0, str_Sort_KB);
                //ADD BY Michael Date:2009-01-14
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_NsykJisseki_SUB_Lot_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }
        #endregion

        #endregion

        #region "Stock Inquiry"

        /// <summary>
        /// Get Stock Inquiry Sum Stock
        /// 
        /// Author:Michael
        /// Create Date:2008-11-26
        /// </summary>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Nins_CD">Consignor Code</param>
        /// <param name="str_Shoh_CD">Product Code</param>
        /// <param name="str_Jyot_KB">Condition</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Reference_StockInfo_GetData_StockInfo(string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_Jyot_KB, string str_SECTION_CODE,string str_Flag)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[6];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyot_KB);

                //Add by Michael Date:2009-01-14
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Flag", ParameterDirection.Input, SqlDbType.Int, 0, str_Flag);
                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_StockInfo_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_StockInfo_GetData_StockInfo:" + err.Message, "G_F_Reference_StockInfo_GetData_StockInfo");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        /// <summary>
        /// Get Stock Inquiry List Table Data
        /// 
        /// Author:Michael
        /// Create Date:2008-11-26
        /// </summary>
        /// <param name="str_Mode">Mode</param>
        /// <param name="str_Tori_CD">Customer Code</param>
        /// <param name="str_Nins_CD">Consignor Code</param>
        /// <param name="str_Shoh_CD">Product Code</param>
        /// <param name="str_Jyot_KB">Condition</param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Reference_StockInfo_GetData_List(string str_Mode, string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_Jyot_KB, string str_SECTION_CODE,string str_Flag)
        {

            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                DataSet ds = null;

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[7];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyot_KB);

                //Add by Michael Date:2009-01-14
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Flag", ParameterDirection.Input, SqlDbType.Int, 0, str_Flag);
                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_StockInfo_SUB_List_Data_Select", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_StockInfo_GetData_List:" + err.Message, "G_F_Reference_StockInfo_GetData_List");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        /// <summary>
        /// Get Stock Inquiry Loca Table Data
        /// 
        /// Author:Michael
        /// Create Data:2008-11-27
        /// </summary>
        /// <param name="str_PC_NM"></param>
        /// <param name="str_Tori_CD"></param>
        /// <param name="str_Nins_CD"></param>
        /// <param name="str_Shoh_CD"></param>
        /// <param name="str_Jyot_KB"></param>
        /// <param name="str_Souk_CD"></param>
        /// <param name="str_Loca_CD"></param>
        /// <param name="str_Begi_QT"></param>
        /// <param name="str_Cyos_QT"></param>
        /// <param name="str_Start_Date"></param>
        /// <param name="str_End_Date"></param>
        /// <returns>DataTable</returns>
        public static DataTable G_F_Reference_StockInfo_Sub_GetData_Loca(string str_PC_NM, string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_Jyot_KB,
                                                                         string str_Souk_CD, string str_Loca_CD, string str_Begi_QT, string str_Cyos_QT, string str_Start_Date, string str_End_Date, string str_SECTION_CODE)
        {

            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[12];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyot_KB);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Souk_CD);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Loca_CD);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Begi_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Begi_QT);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cyos_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Cyos_QT);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Start_Date", ParameterDirection.Input, SqlDbType.DateTime, 0, str_Start_Date);

                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@End_Date", ParameterDirection.Input, SqlDbType.DateTime, 0, str_End_Date);
                //Add by Michael Date:2009-01-14
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);


                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_StockInfo_SUB_Detail_Loca_Data_Select", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {


                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_StockInfo_Sub_GetData_Loca:" + err.Message, "G_F_Reference_StockInfo_Sub_GetData_Loca");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        /// <summary>
        /// Get Stock Inquiry All Table Data
        /// </summary>
        /// <param name="str_PC_NM"></param>
        /// <param name="str_Tori_CD"></param>
        /// <param name="str_Nins_CD"></param>
        /// <param name="str_Shoh_CD"></param>
        /// <param name="str_Jyot_KB"></param>
        /// <param name="str_Nyuk_DT"></param>
        /// <param name="str_Iri_QT"></param>
        /// <param name="str_Souk_CD"></param>
        /// <param name="str_Loca_CD"></param>
        /// <param name="str_Begi_QT"></param>
        /// <param name="str_Cyos_QT"></param>
        /// <param name="str_Start_Date"></param>
        /// <param name="str_End_Date"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_StockInfo_Sub_GetData_ALL(string str_PC_NM, string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_Jyot_KB,
                                                                        string str_Nyuk_DT, string str_Iri_QT, string str_Souk_CD, string str_Loca_CD, string str_Begi_QT,
                                                                        string str_Cyos_QT, string str_Start_Date, string str_End_Date, string str_SECTION_CODE, string str_Lot_CD)
        {

            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[15];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyot_KB);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nyuk_DT", ParameterDirection.Input, SqlDbType.DateTime, 0, str_Nyuk_DT);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Iri_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Iri_QT);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Souk_CD);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Loca_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Loca_CD);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Begi_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Begi_QT);

                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cyos_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Cyos_QT);
                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Start_Date", ParameterDirection.Input, SqlDbType.DateTime, 0, str_Start_Date);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@End_Date", ParameterDirection.Input, SqlDbType.DateTime, 0, str_End_Date);
                //Add by Michael Date:2009-01-14
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);
                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Lot_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Lot_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_StockInfo_SUB_Detail_ALL_Data_Select", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_StockInfo_Sub_GetData_ALL:" + err.Message, "G_F_Reference_StockInfo_Sub_GetData_ALL");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        /// <summary>
        /// Get Stock Inquiry Product Table Data
        /// 
        /// Author:Michael
        /// Create Date:2008-11-27
        /// </summary>
        /// <param name="str_PC_NM"></param>
        /// <param name="str_Tori_CD"></param>
        /// <param name="str_Nins_CD"></param>
        /// <param name="str_Shoh_CD"></param>
        /// <param name="str_Jyot_KB"></param>
        /// <param name="str_Begi_QT"></param>
        /// <param name="str_Cyos_QT"></param>
        /// <param name="str_Start_Date"></param>
        /// <param name="str_End_Date"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_StockInfo_Sub_GetData_Shoh(string str_PC_NM, string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_Jyot_KB,
                                                                         string str_Begi_QT, string str_Cyos_QT, string str_Start_Date, string str_End_Date, string str_SECTION_CODE)
        {

            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[10];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyot_KB);


                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Begi_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Begi_QT);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cyos_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Cyos_QT);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Start_Date", ParameterDirection.Input, SqlDbType.DateTime, 0, str_Start_Date);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@End_Date", ParameterDirection.Input, SqlDbType.DateTime, 0, str_End_Date);
                //Add by Michael Date:2009-01-14
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_StockInfo_SUB_Detail_Shoh_Data_Select", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {


                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_StockInfo_Sub_GetData_Shoh:" + err.Message, "G_F_Reference_StockInfo_Sub_GetData_Shoh");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        /// <summary>
        /// Update Data
        /// 
        /// Author:Michael
        /// Create Date:2008-11-27
        /// </summary>
        /// <param name="str_ID"></param>
        /// <param name="str_Begi_QT"></param>
        /// <param name="str_Curt_QT"></param>
        /// <param name="str_Cyos_QT"></param>
        /// <param name="str_Prio_NO"></param>
        /// <param name="str_Pend_FG"></param>
        /// <returns></returns>
        public static int G_G_F_Reference_StockInfo_Update(string str_ID, string str_Begi_QT, string str_Curt_QT, string str_Cyos_QT, string str_Prio_NO, string str_Pend_FG)
        {
            int result = -11;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[7];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ID", ParameterDirection.Input, SqlDbType.Int, 0, str_ID);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Begi_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Begi_QT);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Curt_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Curt_QT);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cyos_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Cyos_QT);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Prio_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_Prio_NO);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Pend_FG", ParameterDirection.Input, SqlDbType.Int, 0, str_Pend_FG);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;
                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_StockInfo_DataUpdate", sqlPara, out sqloutPara);

                result = int.Parse(sqloutPara[0].Value.ToString());
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_G_F_Reference_StockInfo_Update:" + err.Message, "G_G_F_Reference_StockInfo_Update");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }



        /// <summary>
        /// Get Stock Inquiry Product Table Data
        /// 
        /// Author:Michael
        /// Create Date:2008-11-27
        /// </summary>
        /// <param name="str_PC_NM"></param>
        /// <param name="str_Tori_CD"></param>
        /// <param name="str_Nins_CD"></param>
        /// <param name="str_Shoh_CD"></param>
        /// <param name="str_Jyot_KB"></param>
        /// <param name="str_Begi_QT"></param>
        /// <param name="str_Cyos_QT"></param>
        /// <param name="str_Start_Date"></param>
        /// <param name="str_End_Date"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_StockInfo_Sub_GetData_Lot(string str_PC_NM, string str_Tori_CD, string str_Nins_CD, string str_Shoh_CD, string str_Jyot_KB,
                                                                         string str_Begi_QT, string str_Cyos_QT, string str_Start_Date, string str_End_Date, string str_SECTION_CODE,string str_Lot_CD)
        {

            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[11];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Tori_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Nins_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyot_KB);


                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Begi_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Begi_QT);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cyos_QT", ParameterDirection.Input, SqlDbType.Int, 0, str_Cyos_QT);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Start_Date", ParameterDirection.Input, SqlDbType.DateTime, 0, str_Start_Date);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@End_Date", ParameterDirection.Input, SqlDbType.DateTime, 0, str_End_Date);
                //Add by Michael Date:2009-01-14
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);
                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Lot_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Lot_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_StockInfo_SUB_Detail_Lot_Data_Select", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {


                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_StockInfo_Sub_GetData_Shoh:" + err.Message, "G_F_Reference_StockInfo_Sub_GetData_Shoh");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        #endregion

        #region"Delivery Status Inquiry"

        #region "Search"

        /// <summary>
        /// Get Delivery Status Inquiry Data
        /// 
        /// Author:Michael
        /// Create Date:2008-11-28
        /// </summary>
        /// <param name="str_Target_DT"></param>
        /// <param name="str_Attribute_CD"></param>
        /// <param name="str_Sort_KB"></param>
        /// <returns></returns>
        public static DataTable G_F_Reference_SykStateInfo_GetData(string str_Target_DT, string str_Attribute_CD, string str_Sort_KB, string str_SECTION_CODE)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[4];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Target_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Target_DT);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Attribute_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Attribute_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Sort_KB", ParameterDirection.Input, SqlDbType.Int, 0, str_Sort_KB);
                //Add by Michael Date:2009-01-14
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Reference_SykStateInfo_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Reference_SykStateInfo_GetData:" + err.Message, "G_F_Reference_SykStateInfo_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion

        #endregion


        #endregion

        #region "Private Method"

        public static void P_MessageBox_Connection()
        {
            string strMessage = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_ConnectionError);
            string strCaption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
            MessageBox.Show(strMessage, strCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        public static void P_MessageBox_Disconnection()
        {
            string strMessage = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_DisconnectionError);
            string strCaption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
            MessageBox.Show(strMessage, strCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        #endregion

        #region Picking List Report export
        public static void PickingListReport_Old(DataTable dt)
        {
            string str_Message, str_Caption;
            int int_PrintCount = dt.Rows.Count;

            for (int i = 0; i < int_PrintCount; i++)
            {
                string str_Print_Pic_No = dt.Rows[i]["Pic_No"].ToString();


                ////セット構成リスト出力
                //this.P_PrintShohSetList(str_Print_Pic_No);

                //Report
                ExcelAccess xlReport = new ExcelAccess();

                string strPath = Application.StartupPath + @"\Report";
                string strExcelTemplateFile = System.IO.Path.GetFullPath(strPath + @"\PickingList.xlt");

                if (!System.IO.File.Exists(strExcelTemplateFile))
                {
                    str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Excel_Template_NoExists);
                    str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                    MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                DataTable dtReport = G_F_Mortgage_PrintPickingList_GetData(str_Print_Pic_No, G_CommonDefine.G_PCNM);

                if ((dtReport == null) || (dtReport.Rows.Count == 0))
                {
                    return;
                }
                QRCodeEncoder pickingNo = new QRCodeEncoder();
                pickingNo.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
                pickingNo.QRCodeScale = 2;
                pickingNo.QRCodeVersion = 7;
                pickingNo.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
                string str_Pic_No = dtReport.Rows[0]["Pic_No_Barcode"].ToString();
                Image image = pickingNo.Encode(str_Pic_No);
                string str_ImageFile = @"c:\temp.Jpeg";
                System.IO.FileStream fs = new System.IO.FileStream(str_ImageFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
                image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
                fs.Close();
                xlReport.Open(strExcelTemplateFile);
                xlReport.IsVisibledExcel = true;

                xlReport.InsertPicture(3, "B", 7, "C", str_ImageFile);//QRCode

                System.IO.File.Delete(str_ImageFile);
                //
                //Set Header
                //
                Microsoft.Office.Interop.Excel.Range range;
                Object oMissing = System.Reflection.Missing.Value;

                xlReport.SetCellText(2, "L", 2, "M", dtReport.Rows[0]["unso_NM"].ToString());//Delivery Method
                xlReport.SetCellText(3, "G", 3, "I", dtReport.Rows[0]["PIC_NO"].ToString());//PIC_NO
                xlReport.SetCellText(3, "L", 3, "M", DateTime.Now.ToString("yyyy-MM-dd"));//Print Date
                xlReport.SetCellText(4, "L", 4, "M", DateTime.Now.ToString("HH:mm:ss"));//Print Time
                //xlReport.SetCellText(3, "L", 3, "M", dtReport.Rows[0]["Uria_DT"].ToString());//Invoice Date
                //xlReport.SetCellText(4, "L", 4, "M", dtReport.Rows[0]["Time_NM"].ToString());//Time
                xlReport.SetCellText(4, "E", 4, "F", dtReport.Rows[0]["Uria_DT"].ToString());//Delivery Date
                xlReport.SetCellText(5, "E", 5, "F", dtReport.Rows[0]["Nouk_DT"].ToString());//ｽｻｻﾕﾆﾚ

                xlReport.SetCellText(5, "J", dtReport.Rows[0]["POS_CT"].ToString());//ｽｻｻﾕﾆﾚ

                //xlReport.SetCellText(8, "A", 8, "I", dtReport.Rows[0]["Tori_CD"].ToString());//ｿﾍﾈﾋﾃ﨤ﾆ
                range = xlReport.GetRange(9, "A", 9, "B");
                range.Merge(oMissing);
                range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                xlReport.SetCellText(9, "A", 9, "B", dtReport.Rows[0]["Todo_CD"].ToString());//ﾊﾕｻﾋｱ犲ﾅ
                range = xlReport.GetRange(9, "C", 9, "I");
                range.Merge(oMissing);
                range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                xlReport.SetCellText(9, "C", 9, "I", dtReport.Rows[0]["Todo_NM"].ToString());//ﾊﾕﾎ・ﾋﾃ﨤ﾆ
                range = xlReport.GetRange(10, "C");
                range.Merge(oMissing);
                range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                xlReport.SetCellText(10, "C", dtReport.Rows[0]["Tdzip_NO"].ToString());//ﾓﾊﾕｱ狡・
                range = xlReport.GetRange(10, "D", 10, "I");
                range.Merge(oMissing);
                range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                xlReport.SetCellText(10, "D", 10, "I", dtReport.Rows[0]["Todo_AD"].ToString());//ｵﾘﾖｷ
                range = xlReport.GetRange(11, "C", 11, "D");
                range.Merge(oMissing);
                range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                xlReport.SetCellText(11, "C", 11, "D", dtReport.Rows[0]["TdTel_NO"].ToString());//ｵ扈ｰ

                //xlReport.SetCellText(11, "F", 11, "G", dtReport.Rows[0][""].ToString());//ｴｫﾕ・
                range = xlReport.GetRange(11, "J", 11, "L");
                range.Merge(oMissing);
                range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                xlReport.SetCellText(11, "J", 11, "L", dtReport.Rows[0]["Bik_04_TXT"].ToString());//ｹ貂・

                xlReport.SetCellText(11, "M", dtReport.Rows[0]["Konp_NM"].ToString());//ｰ・ｰﾋｵﾃ・
                range = xlReport.GetRange(12, "C", 12, "M");
                range.Merge(oMissing);
                range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                xlReport.SetCellText(12, "C", 12, "M", dtReport.Rows[0]["Bik_01_TXT"].ToString());//ｷ｢ﾆｱﾕｪﾒｪ
                range = xlReport.GetRange(13, "C", 13, "M");
                range.Merge(oMissing);
                range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                xlReport.SetCellText(13, "C", 13, "M", dtReport.Rows[0]["Bik_02_TXT"].ToString());//ｿﾍｻｧｱｸﾗ｢
                range = xlReport.GetRange(14, "C", 14, "M");
                range.Merge(oMissing);
                range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                xlReport.SetCellText(14, "C", 14, "M", dtReport.Rows[0]["Instructions"].ToString());//ﾌﾘｱﾂﾏ・
                //
                //
                //
                Microsoft.Office.Interop.Excel.Range bgColor = xlReport.GetRange(15, "A");
                Microsoft.Office.Interop.Excel.Range fgFont = xlReport.GetRange(15, "G", 17, "G");

                for (int j = 0; j < dtReport.Rows.Count; j++)
                {
                    int RowIndex = 15 + j * 3;


                    range = xlReport.GetRange(RowIndex, "A");
                    range.Interior.Color = bgColor.Interior.Color;

                    range = xlReport.GetRange(RowIndex, "B", RowIndex, "C");
                    range.Merge(oMissing);
                    xlReport.SetCellText(RowIndex, "B", RowIndex, "C", dtReport.Rows[j]["Loca_CD"].ToString());//ﾎｻﾖﾃxl

                    range = xlReport.GetRange(RowIndex, "D", RowIndex, "E");
                    range.Interior.Color = bgColor.Interior.Color;
                    range.Merge(oMissing);
                    xlReport.SetCellText(RowIndex, "D", RowIndex, "E", dtReport.Rows[j]["Shoh_CD"].ToString());//Product Code

                    xlReport.SetCellText(RowIndex, "F", dtReport.Rows[j]["Data_NM"].ToString());//Condition

                    range = xlReport.GetRange(RowIndex, "G", RowIndex + 2, "G");
                    range.Merge(oMissing);

                    range.Borders.LineStyle = 1;
                    range.Font.Size = 14;
                    range.Font.Bold = true;
                    range.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;
                    range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;

                    xlReport.SetBordersEdge(range, BordersEdge.xlInsideHorizontal);
                    xlReport.SetCellText(RowIndex, "G", RowIndex + 2, "G", dtReport.Rows[j]["Yote_QT"].ToString());//Instructed Qty 6 ﾏ・

                    range = xlReport.GetRange(RowIndex, "H", RowIndex + 2, "H");
                    range.Merge(oMissing);
                    xlReport.SetCellText(RowIndex, "H", RowIndex + 2, "H", dtReport.Rows[j]["Tani_NM"].ToString());//Unit

                    range = xlReport.GetRange(RowIndex, "I");
                    range.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;
                    range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                    xlReport.SetCellText(RowIndex, "I", "MOQ:");
                    range = xlReport.GetRange(RowIndex, "J");
                    range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                    xlReport.SetCellText(RowIndex, "J", dtReport.Rows[j]["Iri_QT"].ToString());//Moq

                    range = xlReport.GetRange(RowIndex + 1, "I");
                    range.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;
                    range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                    xlReport.SetCellText(RowIndex + 1, "I", "入库日期:");

                    range = xlReport.GetRange(RowIndex + 1, "J", RowIndex + 1, "K");
                    range.Merge(oMissing);
                    range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                    xlReport.SetCellText(RowIndex + 1, "J", RowIndex + 1, "K", dtReport.Rows[j]["Nyuk_DT"].ToString());//ﾎｻﾖﾃ
                    range = xlReport.GetRange(RowIndex + 2, "I");
                    range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
                    xlReport.SetCellText(RowIndex + 2, "I", dtReport.Rows[j]["Disp_WT"].ToString());//KG


                    xlReport.SetCellText(RowIndex + 2, "J", "箱数:");
                    range = xlReport.GetRange(RowIndex + 2, "K");
                    range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                    range.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;
                    xlReport.SetCellText(RowIndex + 2, "K", dtReport.Rows[j]["Ha_QT"].ToString());//Box Qty

                    range = xlReport.GetRange(RowIndex + 2, "L");
                    range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    xlReport.SetCellText(RowIndex + 2, "L", dtReport.Rows[j]["Hako_QT"].ToString());//ｶﾋﾊ｣ｺ0


                    range = xlReport.GetRange(RowIndex + 1, "A", RowIndex + 1, "F");
                    range.Merge(oMissing);
                    range.Interior.Color = bgColor.Interior.Color;
                    xlReport.SetCellText(RowIndex + 1, "A", RowIndex + 1, "F", dtReport.Rows[j]["Shoh_NM"].ToString());//Product Name


                    QRCodeEncoder product = new QRCodeEncoder();
                    product.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
                    product.QRCodeScale = 2;
                    product.QRCodeVersion = 7;
                    product.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;

                    image = product.Encode(dtReport.Rows[j]["Shoh_CD"].ToString());
                    System.IO.FileStream fs1 = new System.IO.FileStream(str_ImageFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
                    image.Save(fs1, System.Drawing.Imaging.ImageFormat.Jpeg);
                    fs1.Close();
                    range = xlReport.GetRange(RowIndex, "M", RowIndex + 2, "M");
                    range.Merge(oMissing);
                    range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
                    range.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;

                    xlReport.InsertPicture(RowIndex, "M", RowIndex + 2, "M", str_ImageFile);

                    System.IO.File.Delete(str_ImageFile);

                    range = xlReport.GetRange(RowIndex, "A", RowIndex + 2, "M");
                    xlReport.SetBordersEdge(range, BordersEdge.xlBottom);
                }
                //xlReport.PrintPreview();
                //xlReport.Close();
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "(*.xls)|*.xls|(*.*)|*.*";
                saveFileDialog.FileName = "PickingList" + DateTime.Now.ToString("yyyyMMddHHmmss");
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    xlReport.SaveAs(saveFileDialog.FileName, true);
                }
                xlReport.Close();
            }
        }

        /// <summary>
        /// Picking List Report 
        /// </summary>
        /// <param name="dt"></param>
        public static void PickingListReport(DataTable dt)
        {
            string str_Message, str_Caption;
            int int_PrintCount = dt.Rows.Count;

            for (int i = 0; i < int_PrintCount; i++)
            {
                string str_Print_Pic_No = dt.Rows[i]["Pic_No"].ToString();

                //bool isEnblishVersion = false;
                bool isSHVersion = false;


                ExcelAccess xlReport = new ExcelAccess();
                string strPath = Application.StartupPath + @"\Report";

                string strExcelTemplateFile = System.IO.Path.GetFullPath(strPath + @"\PickingList.xlt");
                string str_Language = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString();
                switch (str_Language)
                {
                    case "en":
                        strExcelTemplateFile = System.IO.Path.GetFullPath(strPath + @"\PickingListEN.xlt");
                        if (!System.IO.File.Exists(strExcelTemplateFile))
                        {
                            strExcelTemplateFile = System.IO.Path.GetFullPath(strPath + @"\PickingList.xlt");
                        }
                        break;
                    case "zh-CHS":
                        strExcelTemplateFile = System.IO.Path.GetFullPath(strPath + @"\PickingListCN.xlt");
                        if (!System.IO.File.Exists(strExcelTemplateFile))
                        {
                            strExcelTemplateFile = System.IO.Path.GetFullPath(strPath + @"\PickingList.xlt");
                        }
                        break;
                    default:
                        break;
                }

                if (G_CommonDefine.G_str_Customer_CD == "FESH")
                {
                    DataTable dt_Temp = G_CommonClassBussniss.G_M_Define_HD_GetData();

                    if ((dt_Temp != null) && (dt_Temp.Select("Item_CD='05' AND Item_Value='FESH'").Length > 0))
                    {
                        //上海 SH
                        isSHVersion = true;
                        strExcelTemplateFile = System.IO.Path.GetFullPath(strPath + @"\PickingList.xlt");
                    }
                    else
                    {
                        //深圳 SZ
                        isSHVersion = false;
                    }
                }
               

                if (!System.IO.File.Exists(strExcelTemplateFile))
                {
                    str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Excel_Template_NoExists);
                    str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                    MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                DataTable dtReport = G_F_Mortgage_PrintPickingList_GetData(str_Print_Pic_No, G_CommonDefine.G_PCNM);

                if ((dtReport == null) || (dtReport.Rows.Count == 0))
                {
                    return;
                }


                xlReport.Open(strExcelTemplateFile);
                xlReport.IsVisibledExcel = true;


                if (isSHVersion == true)
                {
                    //上海 SH
                    P_DrawPickingListReport_Multipage_SH(xlReport, dtReport, strExcelTemplateFile);
                }
                else
                {
                    P_DrawPickingListReport_Multipage_EN(xlReport, dtReport, strExcelTemplateFile);
                }
            }
        }

        //private static void P_DrawPickingListReport_Multipage(ExcelAccess xlReport, DataTable dtReport, string strExcelTemplateFile)
        //{

        //    int pageChild = 0; //当前页 Current Page
        //    int pageParent = 1;//总页数 Total Page
        //    int baseIndex = 0;
        //    int PageTotalRowCount = 48;// 每页打印48行,第二页从49行开始
        //    int PagePrintRowCount = 9;//明细每页打印9行数据 Excel 明细行为 3*9 行
        //    //每页打印9行
        //    //pageParent = dtReport.Rows.Count / PagePrintRowCount;
        //    //if ((dtReport.Rows.Count % PagePrintRowCount) != 0)
        //    //{
        //    //    pageParent += 1;
        //    //}
        //    //根据Zone (Loca_CD 前三位来分页)

        //    pageParent = Convert.ToInt32(dtReport.Rows[0]["PageParent"].ToString());

        //    int PageOneIndexStart = 0;
        //    int PageOneIndexEnd = 0;

        //    int columnIndex = 0;

        //    Microsoft.Office.Interop.Excel.Range range;
        //    Microsoft.Office.Interop.Excel.Range subRange;
        //    Object oMissing = System.Reflection.Missing.Value;

        //    int int_total = P_PickListReport_GetTotal(dtReport); ;//总数量

        //    int int_famount = 0;                 //当前页的总数量
        //    for (pageChild = 0; pageChild < pageParent; pageChild++)
        //    {
        //        baseIndex = pageChild * PageTotalRowCount;//每页48行 baseIndex + 1  则为当前页的起始行
        //        //columnIndex = pageChild * PagePrintRowCount;//每行打印9行明细记录
        //        //rowIndex = 1 + baseIndex;
        //        if (pageChild != 0)
        //        {
        //            subRange = xlReport.GetRange(1, "A", 17, "M");
        //            subRange.Copy(oMissing);
        //            range = xlReport.GetRange(baseIndex + 1, "A", baseIndex + 17, "M");
        //            range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, oMissing, oMissing);
        //            //设置行高。不知道什么原因。第一二行会变宽
        //            //range = xlReport.GetRange(baseIndex + 1, "A", baseIndex + 2, "M");
        //            range.RowHeight = 13.5;
        //        }

        //        //每页表头
        //        //生成Picking List BarCode
        //        QRCodeEncoder pickingNo = new QRCodeEncoder();
        //        pickingNo.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
        //        pickingNo.QRCodeScale = 2;
        //        pickingNo.QRCodeVersion = 7;
        //        pickingNo.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
        //        string str_Pic_No = dtReport.Rows[columnIndex]["Pic_No_Barcode"].ToString();
        //        Image image = pickingNo.Encode(str_Pic_No);
        //        string str_ImageFile = @"c:\temp.Jpeg";
        //        System.IO.FileStream fs = new System.IO.FileStream(str_ImageFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
        //        image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
        //        fs.Close();

        //        range = xlReport.GetRange(baseIndex + 3, "B", baseIndex + 7, "C");
        //        range.Merge(oMissing);
        //        xlReport.InsertPicture(baseIndex + 3, "B", baseIndex + 7, "C", str_ImageFile);//QRCode

        //        System.IO.File.Delete(str_ImageFile);
        //        //
        //        //Set Header
        //        //
        //        //打印页码
        //        range = xlReport.GetRange(baseIndex + 2, "J", baseIndex + 2, "K");
        //        range.Merge(oMissing);
        //        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
        //        xlReport.SetCellText(range, string.Format("页数 {0}/{1}", pageChild + 1, pageParent));

        //        if (pageChild == 0)
        //        {
        //            //Reprint_Flag
        //            range = xlReport.GetRange(baseIndex + 2, "A", baseIndex + 2, "B");
        //            range.Merge(oMissing);
        //            range.Font.Bold = true;
        //            //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlLineStyleNone;
        //            xlReport.SetCellText(baseIndex + 2, "A", baseIndex + 2, "B", dtReport.Rows[0]["RePrint_FG"].ToString());
        //            //PIC_NO
        //            range = xlReport.GetRange(baseIndex + 3, "G", baseIndex + 3, "I");
        //            range.Merge(oMissing);
        //            xlReport.SetCellText(baseIndex + 3, "G", baseIndex + 3, "I", dtReport.Rows[0]["PIC_NO"].ToString());
        //            //Delivery Date
        //            xlReport.SetCellText(baseIndex + 4, "D", "出库日期：");
        //            range = xlReport.GetRange(baseIndex + 4, "E", baseIndex + 4, "F");
        //            range.Merge(oMissing);
        //            range.NumberFormat = "yyyy-MM-dd";
        //            xlReport.SetCellText(baseIndex + 4, "E", baseIndex + 4, "F", dtReport.Rows[0]["Siji_DT"].ToString());
        //            //Promise Date
        //            xlReport.SetCellText(baseIndex + 5, "D", "交货日期：");
        //            range = xlReport.GetRange(baseIndex + 5, "E", baseIndex + 5, "F");
        //            range.Merge(oMissing);
        //            range.NumberFormat = "yyyy-MM-dd";
        //            xlReport.SetCellText(baseIndex + 5, "E", baseIndex + 5, "F", dtReport.Rows[0]["Nouk_DT"].ToString());
        //            //Order Date 订单日期
        //            xlReport.SetCellText(baseIndex + 4, "G", "订单日期：");
        //            range = xlReport.GetRange(baseIndex + 4, "H", baseIndex + 4, "I");
        //            range.Merge(oMissing);
        //            range.NumberFormat = "yyyy-MM-dd";
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
        //            xlReport.SetCellText(baseIndex + 4, "H", baseIndex + 4, "I", dtReport.Rows[0]["Jytu_DT"].ToString());
        //            //Invoice NO
        //            xlReport.SetCellText(baseIndex + 5, "G", "通知书号：");
        //            range = xlReport.GetRange(baseIndex + 5, "H", baseIndex + 5, "I");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
        //            xlReport.SetCellText(baseIndex + 5, "H", baseIndex + 5, "I", dtReport.Rows[0]["Cust_NO"].ToString());
        //            //SO NO
        //            xlReport.SetCellText(baseIndex + 6, "G", "合同号：");
        //            range = xlReport.GetRange(baseIndex + 6, "H", baseIndex + 6, "I");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
        //            xlReport.SetCellText(baseIndex + 6, "H", baseIndex + 6, "I", dtReport.Rows[0]["Jyht_NO"].ToString());
        //            //CPO NO
        //            xlReport.SetCellText(baseIndex + 7, "G", "客户订单:");
        //            range = xlReport.GetRange(baseIndex + 7, "H", baseIndex + 7, "M");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
        //            range.NumberFormat = "@";
        //            xlReport.SetCellText(baseIndex + 7, "H", baseIndex + 7, "M", dtReport.Rows[0]["Ktyu_NO"].ToString());
        //            //POS COUNT 显示明细有多少行
        //            xlReport.SetCellText(baseIndex + 5, "J", dtReport.Rows.Count.ToString());
        //            xlReport.SetCellText(baseIndex + 5, "K", "POS");
        //            //Print Date
        //            range = xlReport.GetRange(baseIndex + 3, "L", baseIndex + 3, "M");
        //            range.Merge(oMissing);
        //            range.NumberFormat = "yyyy-MM-dd";
        //            xlReport.SetCellText(baseIndex + 3, "L", baseIndex + 3, "M", DateTime.Now.ToString("yyyy-MM-dd"));
        //            //Print Time
        //            range = xlReport.GetRange(baseIndex + 4, "L", baseIndex + 4, "M");
        //            range.Merge(oMissing);
        //            range.NumberFormat = "HH:mm:ss";
        //            xlReport.SetCellText(baseIndex + 4, "L", baseIndex + 4, "M", DateTime.Now.ToString("HH:mm:ss"));

        //            //仓库
        //            xlReport.SetCellText(baseIndex + 6, "J", "仓库：");
        //            range = xlReport.GetRange(baseIndex + 6, "K", baseIndex + 6, "M");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
        //            xlReport.SetCellText(range, dtReport.Rows[0]["Souk_NM"].ToString());

        //            //画直线
        //            range = xlReport.GetRange(baseIndex + 8, "A", baseIndex + 8, "I");
        //            range.Merge(oMissing);
        //            range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;
        //            //发货方Destion Information
        //            //Name
        //            range = xlReport.GetRange(baseIndex + 9, "A", baseIndex + 9, "B");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
        //            xlReport.SetCellText(baseIndex + 9, "A", baseIndex + 9, "B", "致：");
        //            range = xlReport.GetRange(baseIndex + 9, "C", baseIndex + 9, "I");
        //            range.Merge(oMissing);
        //            range.Font.Bold = true;
        //            xlReport.SetCellText(baseIndex + 9, "C", baseIndex + 9, "I", dtReport.Rows[0]["Todo_NM"].ToString());
        //            //Address
        //            range = xlReport.GetRange(baseIndex + 10, "A", baseIndex + 10, "B");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
        //            xlReport.SetCellText(baseIndex + 10, "A", baseIndex + 10, "B", "地址：");
        //            range = xlReport.GetRange(baseIndex + 10, "C", baseIndex + 10, "I");
        //            range.Merge(oMissing);
        //            range.Font.Bold = true;
        //            string str_Todo_AD = dtReport.Rows[0]["Todo_AD"].ToString();
        //            string str_TdZip_NO = dtReport.Rows[0]["TdZip_NO"].ToString();
        //            if (str_TdZip_NO.Length > 0)
        //            {
        //                str_Todo_AD = dtReport.Rows[0]["TdZip_NO"].ToString() + " " + str_Todo_AD;
        //            }
        //            xlReport.SetCellText(baseIndex + 10, "C", baseIndex + 10, "I", str_Todo_AD);
        //            //Telphone
        //            range = xlReport.GetRange(baseIndex + 11, "A", baseIndex + 11, "B");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
        //            xlReport.SetCellText(baseIndex + 11, "A", baseIndex + 11, "B", "电话：");
        //            range = xlReport.GetRange(baseIndex + 11, "C", baseIndex + 11, "I");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
        //            xlReport.SetCellText(baseIndex + 11, "C", baseIndex + 11, "I", dtReport.Rows[0]["TdTel_NO"].ToString());

        //            //画直线
        //            range = xlReport.GetRange(baseIndex + 11, "A", baseIndex + 11, "I");
        //            range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;

        //            //收货方 Order Customer Information
        //            //Order Customer Name
        //            range = xlReport.GetRange(baseIndex + 12, "A", baseIndex + 12, "B");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
        //            xlReport.SetCellText(baseIndex + 12, "A", baseIndex + 12, "B", "客户：");
        //            range = xlReport.GetRange(baseIndex + 12, "C", baseIndex + 12, "I");
        //            range.Merge(oMissing);
        //            range.Font.Bold = true;
        //            xlReport.SetCellText(baseIndex + 12, "C", baseIndex + 12, "I", dtReport.Rows[0]["Toku_NM"].ToString());
        //            //Address
        //            range = xlReport.GetRange(baseIndex + 13, "A", baseIndex + 13, "B");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
        //            xlReport.SetCellText(baseIndex + 13, "A", baseIndex + 13, "B", "客户地址：");
        //            range = xlReport.GetRange(baseIndex + 13, "C", baseIndex + 13, "I");
        //            range.Merge(oMissing);
        //            range.Font.Bold = true;
        //            string str_Toku_AD = dtReport.Rows[0]["Toku_AD"].ToString();
        //            string str_Toku_Zip_NO = dtReport.Rows[0]["Toku_Zip_NO"].ToString();
        //            //string str_Toku_Zip_NO = "";
        //            if (str_Toku_Zip_NO.Length > 0)
        //            {
        //                str_Toku_AD = str_Toku_Zip_NO + " " + str_Toku_AD;
        //            }
        //            xlReport.SetCellText(baseIndex + 13, "C", baseIndex + 13, "I", str_Toku_AD);
        //            //Telphone
        //            range = xlReport.GetRange(baseIndex + 14, "A", baseIndex + 14, "B");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
        //            xlReport.SetCellText(baseIndex + 14, "A", baseIndex + 14, "B", "客户电话：");
        //            range = xlReport.GetRange(baseIndex + 14, "C", baseIndex + 14, "I");
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
        //            range.Merge(oMissing);
        //            xlReport.SetCellText(baseIndex + 14, "C", baseIndex + 14, "I", dtReport.Rows[0]["Toku_Tel_NO"].ToString());
        //            //画直线
        //            range = xlReport.GetRange(baseIndex + 14, "A", baseIndex + 14, "I");
        //            range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;

        //            //其它信息
        //            //运费
        //            range = xlReport.GetRange(baseIndex + 15, "A", baseIndex + 15, "B");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
        //            xlReport.SetCellText(baseIndex + 15, "A", baseIndex + 15, "B", "运费：");
        //            range = xlReport.GetRange(baseIndex + 15, "C", baseIndex + 15, "D");
        //            range.Merge(oMissing);
        //            xlReport.SetCellText(baseIndex + 15, "C", baseIndex + 15, "D", dtReport.Rows[0]["Bik_02_TXT"].ToString());
        //            //交货条件
        //            range = xlReport.GetRange(baseIndex + 15, "E", baseIndex + 15, "F");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
        //            xlReport.SetCellText(baseIndex + 15, "E", baseIndex + 15, "F", "交货条件：");
        //            range = xlReport.GetRange(baseIndex + 15, "G", baseIndex + 15, "I");
        //            range.Merge(oMissing);
        //            xlReport.SetCellText(baseIndex + 15, "G", baseIndex + 15, "I", dtReport.Rows[0]["Bik_03_TXT"].ToString());
        //            //运送方式 应会改
        //            range = xlReport.GetRange(baseIndex + 16, "A", baseIndex + 16, "B");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
        //            xlReport.SetCellText(baseIndex + 16, "A", baseIndex + 16, "B", "付运方式：");
        //            range = xlReport.GetRange(baseIndex + 16, "C", baseIndex + 16, "I");
        //            range.Merge(oMissing);
        //            xlReport.SetCellText(baseIndex + 16, "C", baseIndex + 16, "I", dtReport.Rows[0]["unso_CD"].ToString() + "    " + dtReport.Rows[0]["unso_NM"].ToString());
        //            //备注
        //            range = xlReport.GetRange(baseIndex + 17, "A", baseIndex + 17, "B");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
        //            xlReport.SetCellText(baseIndex + 17, "A", baseIndex + 17, "B", "备注：");
        //            range = xlReport.GetRange(baseIndex + 17, "C", baseIndex + 17, "I");
        //            range.Merge(oMissing);
        //            xlReport.SetCellText(baseIndex + 17, "C", baseIndex + 17, "I", dtReport.Rows[0]["Bik_01_TXT"].ToString());

        //            string Zone_Text = P_Get_Zone_Text(dtReport);
        //            //Zone_Text
        //            range = xlReport.GetRange(baseIndex + 14, "J", baseIndex + 14, "L");
        //            range.Merge(oMissing);
        //            xlReport.SetCellText(baseIndex + 14, "J", baseIndex + 14, "L", Zone_Text);
        //            //Konp_NM 包装区分
        //            xlReport.SetCellText(baseIndex + 14, "M", dtReport.Rows[0]["Konp_NM"].ToString());

        //            //画直线
        //            range = xlReport.GetRange(baseIndex + 17, "A", baseIndex + 17, "M");
        //            range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick;

        //        }
               
        //        //每页明细
        //        int x = 0;
        //        int int_StartIndex = 18 + baseIndex;
        //        int int_EndIndex = 18 + baseIndex + 28;
        //        //设置明细行高
        //        range = xlReport.GetRange(int_StartIndex, "A", int_EndIndex -1 , "A");
        //        range.RowHeight = 19.5;
        //        int_famount = 0;

        //        int int_Pos = 0;
        //        string[,] detailArray = new string[28, 12];
        //        int xx = 0;
        //        //复制明细格式
        //        if (pageChild != 0)
        //        {
        //            subRange = xlReport.GetRange(18, "A", 46, "M");
        //            subRange.Copy(oMissing);
        //            range = xlReport.GetRange(int_StartIndex, "A", int_EndIndex, "M");
        //            range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteFormats, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, oMissing, oMissing);
        //        }
        //        for (int j = columnIndex; (j < columnIndex + 9) && (j < dtReport.Rows.Count) && (Convert.ToInt32(dtReport.Rows[columnIndex]["PageChild"].ToString()) == pageChild + 1); j++)
        //        {

        //            int RowIndex = 18 + x * 3 + baseIndex;

                   
        //            xx = 3 * x;

        //            detailArray[xx, 1] = dtReport.Rows[j]["Loca_CD"].ToString();//Location
        //            detailArray[xx, 3] = dtReport.Rows[j]["Jyot_NM"].ToString();//Condtion
        //            detailArray[xx, 4] = dtReport.Rows[j]["Cust_Shoh_NM"].ToString();//Vender Name

        //            //detailArray[xx + 1, 0] = dtReport.Rows[j]["Shoh_CD"].ToString();//Product CODE
        //            //detailArray[xx + 1, 3] = dtReport.Rows[j]["Lot_CD"].ToString();//Lot No
        //            //detailArray[xx + 2, 0] = dtReport.Rows[j]["Shoh_NM"].ToString();//Product NAME

        //            detailArray[xx + 1, 0] = dtReport.Rows[j]["Shoh_NM"].ToString();

        //            detailArray[xx, 6] = dtReport.Rows[j]["Yote_QT"].ToString();
        //            detailArray[xx, 7] = dtReport.Rows[j]["Tani_NM"].ToString();

        //            detailArray[xx, 8] = "MOQ:";
        //            detailArray[xx, 9] = dtReport.Rows[j]["Iri_QT"].ToString();
        //            float Disp_WT = default(float);
        //            if (float.TryParse(dtReport.Rows[j]["Disp_WT"].ToString(), out Disp_WT))
        //            {
        //                detailArray[xx + 2, 8] = Disp_WT.ToString();
        //            }
        //            else
        //            {
        //                detailArray[xx + 2, 8] = dtReport.Rows[j]["Disp_WT"].ToString();
        //            }

        //            detailArray[xx + 2, 9] = "箱数:";
        //            detailArray[xx + 2, 10] = dtReport.Rows[j]["Hako_QT"].ToString();
        //            detailArray[xx + 2, 11] = string.Format("端数：{0}", dtReport.Rows[j]["Ha_QT"].ToString().Trim());

        //            int_famount = int_famount + Convert.ToInt32(dtReport.Rows[j]["Yote_QT"].ToString());


        //            QRCodeEncoder product = new QRCodeEncoder();
        //            product.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
        //            product.QRCodeScale = 2;
        //            product.QRCodeVersion = 7;
        //            product.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;

        //            image = product.Encode("ProductNo" + dtReport.Rows[j]["Shoh_CD"].ToString());
        //            System.IO.FileStream fs1 = new System.IO.FileStream(str_ImageFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
        //            image.Save(fs1, System.Drawing.Imaging.ImageFormat.Jpeg);
        //            fs1.Close();
        //            range = xlReport.GetRange(RowIndex, "M", RowIndex + 2, "M");
        //            range.Merge(oMissing);
        //            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
        //            range.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;

        //            xlReport.InsertPicture(RowIndex, "M", RowIndex + 2, "M", str_ImageFile);

        //            System.IO.File.Delete(str_ImageFile);

        //            x = x + 1;//下一下行数据
        //            columnIndex++;

        //            int_Pos++; //当前页有多少行
        //        }
        //        //页尾
        //        //设置页尾
        //        //Operator
        //        //最后一页
        //        //最后一页
        //        if (pageChild == 0)
        //        {

        //            if ((int_Pos < PagePrintRowCount) && (int_StartIndex + int_Pos * 3 <= int_EndIndex))
        //            {
        //                PageOneIndexStart = int_StartIndex + int_Pos * 3;
        //                PageOneIndexEnd = int_EndIndex;
        //            }
        //        }
        //        else
        //        {
        //            if ((int_Pos < PagePrintRowCount) && (int_StartIndex + int_Pos * 3 <= int_EndIndex))
        //            {
        //                range = xlReport.GetRange(int_StartIndex + int_Pos * 3, "A", int_EndIndex, "M");
        //                range.Clear();
        //            }
        //        }

        //        range = xlReport.GetRange(int_StartIndex, "A", int_EndIndex - 1, "L");
        //        range.Value2 = detailArray; 

        //        ////POS COUNT 显示明细有多少行
        //        //xlReport.SetCellText(baseIndex + 5, "J", int_Pos.ToString());
        //        //xlReport.SetCellText(baseIndex + 5, "K", "POS");

        //        //因为有两个空行,设小一些

        //        range = xlReport.GetRange(int_EndIndex - 1, "A", int_EndIndex, "A");
        //        range.RowHeight = 10;

        //        if (pageChild > 0)
        //        {
        //            subRange = xlReport.GetRange(47, "A", 48, "M");
        //            subRange.Copy(oMissing);
        //            range = xlReport.GetRange(int_EndIndex + 1, "A", int_EndIndex + 2, "M");
        //            range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, oMissing, oMissing);
        //        }

        //        xlReport.SetCellText(int_EndIndex + 2, "C", dtReport.Rows[0]["Toku_CD"].ToString());

        //        //页数
        //        range = xlReport.GetRange(int_EndIndex + 1, "D", int_EndIndex + 2, "G");
        //        range.Merge(oMissing);
        //        range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
        //        xlReport.SetCellText(range, string.Format("总数 {0}/{1}", int_famount, int_total));

        //        //打印次数 Pout_CT 是每生成一次Picking List M_Sys_Manager 表中的Pout_CT 加1.
        //        xlReport.SetCellText(int_EndIndex + 2, "M", dtReport.Rows[0]["Pout_CT"].ToString());
        //        Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)xlReport.Workbooks.ActiveSheet;
        //        ws.HPageBreaks.Add(xlReport.GetRange(baseIndex + 49, "A"));
        //    }
        //    //设第一页
        //    if ((PageOneIndexStart > 1) && (PageOneIndexEnd > 1))
        //    {
        //        range = xlReport.GetRange(PageOneIndexStart, "A", PageOneIndexEnd, "M");
        //        range.Clear();
        //    }
        //    //保存Excel
        //    //SaveFileDialog saveFileDialog = new SaveFileDialog();
        //    //saveFileDialog.Filter = "(*.xls)|*.xls|(*.*)|*.*";
        //    //saveFileDialog.FileName = "PickingList" + DateTime.Now.ToString("yyyyMMddHHmmss");
        //    //if (saveFileDialog.ShowDialog() == DialogResult.OK)
        //    //{
        //    //    xlReport.SaveAs(saveFileDialog.FileName, true);
        //    //}
        //    //xlReport.Close();
        //    //xlReport.PrintPreview();
        //    xlReport.Print();
        //    xlReport.Close();
        //}

        private static void P_DrawPickingListReport_Multipage_SH(ExcelAccess xlReport, DataTable dtReport, string strExcelTemplateFile)
        {

            int pageChild = 0; //当前页 Current Page
            int pageParent = 1;//总页数 Total Page
            int baseIndex = 0;
            int PageTotalRowCount = 48;// 每页打印48行,第二页从49行开始
            int PagePrintRowCount = 9;//明细每页打印9行数据 Excel 明细行为 3*9 行
            DotNetBarcode bc = new DotNetBarcode(DotNetBarcode.Types.QRCode);
            string str_Binary = "";
            string str_Date = "";

            //每页打印9行

            //根据Zone (Loca_CD 前三位来分页)

            string str_Language = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString();

            int PageOneIndexStart = 0;
            int PageOneIndexEnd = 0;

            pageParent = Convert.ToInt32(dtReport.Rows[0]["PageParent"].ToString());

            int columnIndex = 0;

            Microsoft.Office.Interop.Excel.Range range;
            Microsoft.Office.Interop.Excel.Range subRange;
            Object oMissing = System.Reflection.Missing.Value;

            int int_total = P_PickListReport_GetTotal(dtReport); ;//总数量

            DateTime Nouk_DT = DateTime.Now;

            int int_famount = 0;                 //当前页的总数量
            for (pageChild = 0; pageChild < pageParent; pageChild++)
            {
                baseIndex = pageChild * PageTotalRowCount;//每页48行 baseIndex + 1  则为当前页的起始行
                //columnIndex = pageChild * PagePrintRowCount;//每行打印9行明细记录
                //rowIndex = 1 + baseIndex;
                //复制表头
                if (pageChild != 0)
                {
                    subRange = xlReport.GetRange(1, "A", 17, "M");
                    subRange.Copy(oMissing);
                    range = xlReport.GetRange(baseIndex + 1, "A", baseIndex + 17, "M");
                    range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, oMissing, oMissing);
                    //设置行高。不知道什么原因。第一二行会变宽
                    //range = xlReport.GetRange(baseIndex + 1, "A", baseIndex + 2, "M");
                    range.RowHeight = 13.5;
                }


                //每页表头
                //生成Picking List BarCode
                QRCodeEncoder pickingNo = new QRCodeEncoder();
                pickingNo.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
                pickingNo.QRCodeScale = 2;
                pickingNo.QRCodeVersion = 7;
                pickingNo.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
                string str_Pic_No = dtReport.Rows[columnIndex]["Pic_No_Barcode"].ToString();
                Image image = pickingNo.Encode(str_Pic_No);
                string str_ImageFile = @"c:\temp.Jpeg";
                System.IO.FileStream fs = new System.IO.FileStream(str_ImageFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
                image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
                fs.Close();

                range = xlReport.GetRange(baseIndex + 3, "B", baseIndex + 7, "C");
                range.Merge(oMissing);
                xlReport.InsertPicture(baseIndex + 3, "B", baseIndex + 7, "C", str_ImageFile);//QRCode

                System.IO.File.Delete(str_ImageFile);
                //
                //Set Header
                //
                //Reprint_Flag
                range = xlReport.GetRange(baseIndex + 2, "A", baseIndex + 2, "B");
                range.Merge(oMissing);
                range.Font.Bold = true;
                //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlLineStyleNone;
                xlReport.SetCellText(baseIndex + 2, "A", baseIndex + 2, "B", dtReport.Rows[0]["RePrint_FG"].ToString());

                //打印页码
                range = xlReport.GetRange(baseIndex + 2, "J", baseIndex + 2, "K");
                range.Merge(oMissing);
                range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
                switch (str_Language)
                {
                    case "en":
                        xlReport.SetCellText(range, string.Format("PAGE {0}/{1}", pageChild + 1, pageParent));
                        break;
                    case "zh-CHS":
                        xlReport.SetCellText(range, string.Format("页数 {0}/{1}", pageChild + 1, pageParent));
                        break;
                    default:
                        xlReport.SetCellText(range, string.Format("PAGE {0}/{1}", pageChild + 1, pageParent));
                        break;
                }
                if (pageChild == 0)
                {
                    //PIC_NO
                    range = xlReport.GetRange(baseIndex + 3, "G", baseIndex + 3, "I");
                    range.Merge(oMissing);
                    xlReport.SetCellText(baseIndex + 3, "G", baseIndex + 3, "I", dtReport.Rows[0]["PIC_NO"].ToString());
                    //Delivery Date
                    //xlReport.SetCellText(baseIndex + 4, "D", "Picking Date:");
                    range = xlReport.GetRange(baseIndex + 4, "E", baseIndex + 4, "F");
                    range.Merge(oMissing);
                    range.NumberFormat = "yyyy-MM-dd";
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Siji_DT"].ToString();
                    //Promise Date
                    range = xlReport.GetRange(baseIndex + 5, "E", baseIndex + 5, "F");
                    range.Merge(oMissing);
                    range.NumberFormat = "yyyy-MM-dd";
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Nouk_DT"].ToString();

                    //Order Date 订单日期
                    //xlReport.SetCellText(baseIndex + 4, "G", "Request Date:");
                    range = xlReport.GetRange(baseIndex + 4, "H", baseIndex + 4, "I");
                    range.Merge(oMissing);
                    range.NumberFormat = "yyyy-MM-dd";
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Jytu_DT"].ToString();
                    range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;

                    //Invoice NO

                    range = xlReport.GetRange(baseIndex + 5, "H", baseIndex + 5, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Cust_NO"].ToString();

                    //SO NO

                    range = xlReport.GetRange(baseIndex + 6, "H", baseIndex + 6, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Jyht_NO"].ToString();

                    //CPO NO
                    //xlReport.SetCellText(baseIndex + 7, "G", "Customer PO:");
                    range = xlReport.GetRange(baseIndex + 7, "H", baseIndex + 7, "M");
                    range.Merge(oMissing);
                    range.NumberFormat = "@";
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Ktyu_NO"].ToString();

                    //POS COUNT 显示明细有多少行
                    xlReport.SetCellText(baseIndex + 5, "J", dtReport.Rows.Count.ToString());
                    xlReport.SetCellText(baseIndex + 5, "K", "POS");
                    //Print Date
                    range = xlReport.GetRange(baseIndex + 3, "L", baseIndex + 3, "M");
                    range.Merge(oMissing);
                    range.NumberFormat = "yyyy-MM-dd";
                    xlReport.SetCellText(baseIndex + 3, "L", baseIndex + 3, "M", DateTime.Now.ToString("yyyy-MM-dd"));
                    //Print Time
                    range = xlReport.GetRange(baseIndex + 4, "L", baseIndex + 4, "M");
                    range.Merge(oMissing);
                    range.NumberFormat = "HH:mm:ss";
                    xlReport.SetCellText(baseIndex + 4, "L", baseIndex + 4, "M", DateTime.Now.ToString("HH:mm:ss"));

                    //仓库
                    //range = xlReport.GetRange(baseIndex + 6, "J", baseIndex + 6, "K");
                    //range.Merge(oMissing);
                    //xlReport.SetCellText(range, "WAREHOUSE:");

                    range = xlReport.GetRange(baseIndex + 6, "L", baseIndex + 6, "M");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Souk_NM"].ToString();
                    //// 是否所有POS 已扣减

                    range = xlReport.GetRange(baseIndex + 8, "M", baseIndex + 9, "M");
                    range.Merge(oMissing);
                    range.Font.Size = 16;
                    range.Font.Bold = true;
                    xlReport.SetCellText(baseIndex + 8, "M", baseIndex + 9, "M", dtReport.Rows[0]["Fin_Msg"].ToString());

                    //画直线
                    //range = xlReport.GetRange(baseIndex + 8, "A", baseIndex + 8, "I");
                    //range.Merge(oMissing);
                    //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;
                    //发货方Destion Information
                    //Name
                    //range = xlReport.GetRange(baseIndex + 9, "A", baseIndex + 9, "B");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 9, "A", baseIndex + 9, "B", "TO:");
                    range = xlReport.GetRange(baseIndex + 9, "C", baseIndex + 9, "I");
                    range.Merge(oMissing);
                    range.Font.Bold = true;
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Todo_NM"].ToString();

                    //Address
                    //range = xlReport.GetRange(baseIndex + 10, "A", baseIndex + 10, "B");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 10, "A", baseIndex + 10, "B", "ADDRESS:");
                    range = xlReport.GetRange(baseIndex + 10, "C", baseIndex + 10, "M");
                    range.Merge(oMissing);
                    range.Font.Bold = true;
                    string str_Todo_AD = dtReport.Rows[0]["Todo_AD"].ToString();
                    string str_TdZip_NO = dtReport.Rows[0]["TdZip_NO"].ToString();
                    if (str_TdZip_NO.Length > 0)
                    {
                        str_Todo_AD = dtReport.Rows[0]["TdZip_NO"].ToString() + " " + str_Todo_AD;
                    }
                    range.Cells.FormulaR1C1 = str_Todo_AD;

                    //Telphone
                    //range = xlReport.GetRange(baseIndex + 11, "A", baseIndex + 11, "B");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 11, "A", baseIndex + 11, "B", "TEL:");
                    range = xlReport.GetRange(baseIndex + 11, "C", baseIndex + 11, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["TdTel_NO"].ToString();

                    ////画直线
                    //range = xlReport.GetRange(baseIndex + 11, "A", baseIndex + 11, "I");
                    //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;

                    //收货方 Order Customer Information
                    //Order Customer Name
                    //range = xlReport.GetRange(baseIndex + 12, "A", baseIndex + 12, "B");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 12, "A", baseIndex + 12, "B", "CUSTOMER:");
                    range = xlReport.GetRange(baseIndex + 12, "C", baseIndex + 12, "I");
                    range.Merge(oMissing);
                    range.Font.Bold = true;
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Toku_NM"].ToString();
                    //Address
                    //range = xlReport.GetRange(baseIndex + 13, "A", baseIndex + 13, "B");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 13, "A", baseIndex + 13, "B", "DD:");
                    range = xlReport.GetRange(baseIndex + 13, "C", baseIndex + 13, "M");
                    range.Merge(oMissing);
                    range.Font.Bold = true;
                    string str_Toku_AD = dtReport.Rows[0]["Toku_AD"].ToString();
                    string str_Toku_Zip_NO = dtReport.Rows[0]["Toku_Zip_NO"].ToString();
                    //string str_Toku_Zip_NO = "";
                    if (str_Toku_Zip_NO.Length > 0)
                    {
                        str_Toku_AD = str_Toku_Zip_NO + " " + str_Toku_AD;
                    }
                    range.Cells.FormulaR1C1 = str_Toku_AD;
                    //Telphone
                    //range = xlReport.GetRange(baseIndex + 14, "A", baseIndex + 14, "B");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 14, "A", baseIndex + 14, "B", "TEL:");
                    range = xlReport.GetRange(baseIndex + 14, "C", baseIndex + 14, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Toku_Tel_NO"].ToString();

                    //画直线
                    //range = xlReport.GetRange(baseIndex + 14, "A", baseIndex + 14, "I");
                    //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;

                    //其它信息
                    //运费

                    //交货条件
                    //range = xlReport.GetRange(baseIndex + 15, "F", baseIndex + 15, "G");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(range, "SHIPPING MARK:");

                    range = xlReport.GetRange(baseIndex + 15, "H", baseIndex + 15, "K");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Bik_03_TXT"].ToString();

                    //运送方式 应会改

                    //range = xlReport.GetRange(baseIndex + 15, "A", baseIndex + 15, "B");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 15, "A", baseIndex + 15, "B", "D.METHOD:");
                    range = xlReport.GetRange(baseIndex + 15, "C", baseIndex + 15, "D");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Bik_02_TXT"].ToString(); 

                    //交货条件：付运方式：
                    range = xlReport.GetRange(baseIndex + 15, "G", baseIndex + 15, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Bik_03_TXT"].ToString();

                    range = xlReport.GetRange(baseIndex + 16, "C", baseIndex + 16, "M");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["unso_CD"].ToString() + "    " + dtReport.Rows[0]["unso_NM"].ToString();

                    range = xlReport.GetRange(baseIndex + 17, "C", baseIndex + 17, "M");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Bik_01_TXT"].ToString();


                    string Zone_Text = P_Get_Zone_Text(dtReport);
                    //Zone_Text
                    range = xlReport.GetRange(baseIndex + 14, "J", baseIndex + 14, "L");
                    range.Merge(oMissing);
                    xlReport.SetCellText(baseIndex + 14, "J", baseIndex + 14, "L", Zone_Text);
                    //Konp_NM 包装区分
                    //xlReport.SetCellText(baseIndex + 14, "M", dtReport.Rows[0]["Konp_NM"].ToString());
                    if (dtReport.Rows[0]["Konp_NM"].ToString().Length > 0)
                    {
                        xlReport.SetCellText(baseIndex + 14, "M", "Packing");
                    }
                    else
                    {
                        xlReport.SetCellText(baseIndex + 14, "M", "");
                    }

                    //画直线
                    //range = xlReport.GetRange(baseIndex + 17, "A", baseIndex + 17, "M");
                    //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick;

                }

                //每页明细
                int x = 0;
                int int_StartIndex = 18 + baseIndex;
                int int_EndIndex = 18 + baseIndex + 28;
                ////设置明细行高
                range = xlReport.GetRange(int_StartIndex, "A", int_EndIndex - 1, "A");
                range.RowHeight = 19.5;
                int_famount = 0;

                int int_Pos = 0;
                string[,] detailArray = new string[28, 12];
                int xx = 0;
                //复制明细格式
                if (pageChild != 0)
                {
                    subRange = xlReport.GetRange(18, "A", 46, "M");
                    subRange.Copy(oMissing);
                    range = xlReport.GetRange(int_StartIndex, "A", int_EndIndex, "M");
                    range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteFormats, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, oMissing, oMissing);
                }
                for (int j = columnIndex; (j < columnIndex + 9) && (j < dtReport.Rows.Count) && (Convert.ToInt32(dtReport.Rows[columnIndex]["PageChild"].ToString()) == pageChild + 1); j++)
                {

                    int RowIndex = 18 + x * 3 + baseIndex;

                    xx = 3 * x;

                    detailArray[xx, 1] = dtReport.Rows[j]["Loca_CD"].ToString();//Location
                    detailArray[xx, 3] = dtReport.Rows[j]["Jyot_NM"].ToString();//Condtion
                    detailArray[xx, 4] = dtReport.Rows[j]["Cust_Shoh_NM"].ToString();//Vender Name

                    detailArray[xx + 1, 0] = dtReport.Rows[j]["Shoh_CD"].ToString();//Product CODE
                    //detailArray[xx + 1, 3] = dtReport.Rows[j]["Lot_CD"].ToString();//Lot No
                    //detailArray[xx + 2, 0] = dtReport.Rows[j]["Shoh_NM"].ToString();//Product NAME

                    detailArray[xx, 6] = dtReport.Rows[j]["Yote_QT"].ToString();
                    detailArray[xx, 7] = dtReport.Rows[j]["Tani_NM"].ToString();

                    detailArray[xx, 8] = "MOQ:";
                    //Add by Michael Date:2009-06-16 start
                    detailArray[xx + 1, 8] = dtReport.Rows[j]["Cust_PO"].ToString();
                    //Add by Michael Date:2009-06-16 end
                    detailArray[xx, 9] = dtReport.Rows[j]["Iri_QT"].ToString();
                    float Disp_WT = default(float);
                    if (float.TryParse(dtReport.Rows[j]["Disp_WT"].ToString(), out Disp_WT))
                    {
                        detailArray[xx + 2, 8] = Disp_WT.ToString();
                    }
                    else
                    {
                        detailArray[xx + 2, 8] = dtReport.Rows[j]["Disp_WT"].ToString();
                    }

                    detailArray[xx + 2, 9] = "箱数:";
                    detailArray[xx + 2, 10] = dtReport.Rows[j]["Hako_QT"].ToString();
                    detailArray[xx + 2, 11] = string.Format("端数:{0}", dtReport.Rows[j]["Ha_QT"].ToString().Trim());

                    int_famount = int_famount + Convert.ToInt32(dtReport.Rows[j]["Yote_QT"].ToString());

                    //QRCodeEncoder product = new QRCodeEncoder();
                    //product.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
                    //product.QRCodeScale = 2;
                    //product.QRCodeVersion = 7;
                    //product.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;

                    //image = product.Encode("ProductNo" + dtReport.Rows[j]["Shoh_CD"].ToString());
                    //System.IO.FileStream fs1 = new System.IO.FileStream(str_ImageFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
                    //image.Save(fs1, System.Drawing.Imaging.ImageFormat.Jpeg);
                    //fs1.Close();

                    if (DateTime.TryParse(dtReport.Rows[0]["Nyuk_DT"].ToString(), out Nouk_DT))
                    {
                        str_Date = Nouk_DT.ToString("yyyyMMdd");
                    }
                    else
                    {
                        str_Date = DateTime.Now.ToString("yyyyMMdd");
                    }

                    if (G_CommonDefine.G_str_Customer_CD != "FESH")
                    {
                        //改成Carton Label
                        str_Binary = "N" + SetLenth("100000001", 20) + //FB_NO
                                         SetLenth("1", 5) +            //FBPOS_NO 
                                         SetLenth("1", 5) +             //SEQ_NO
                                         SetLenth(G_CommonDefine.G_str_Customer_CD, 15) +
                                         SetLenth(dtReport.Rows[j]["Shoh_CD"].ToString(), 80) +
                                         SetLenth(dtReport.Rows[j]["Lot_CD"].ToString(), 50) +
                                         SetLenth("10", 2) +
                                         SetLenth(dtReport.Rows[j]["Yote_QT"].ToString(), 5) +
                                         SetLenth(str_Date, 8);
                    }
                    else
                    {
                        str_Binary = "ProductNo" + dtReport.Rows[j]["Shoh_CD"].ToString();
                    }

                    bc.Save(str_Binary, str_ImageFile, 200, 200);

                    range = xlReport.GetRange(RowIndex, "M", RowIndex + 2, "M");

                    xlReport.InsertPictureBmp(RowIndex, "M", RowIndex + 2, "M", str_ImageFile);

                    System.IO.File.Delete(str_ImageFile);

                    range = xlReport.GetRange(RowIndex, "A", RowIndex + 2, "M");
                    xlReport.SetBordersEdge(range, BordersEdge.xlBottom);

                    x = x + 1;//下一下行数据
                    columnIndex++;

                    int_Pos++; //当前页有多少行
                }
                //页尾
                //设置页尾
                //Operator

                range = xlReport.GetRange(int_StartIndex, "A", int_EndIndex - 1, "L");
                range.Value2 = detailArray;

                //最后一页
                if (pageChild == 0)
                {

                    if ((int_Pos < PagePrintRowCount) && (int_StartIndex + int_Pos * 3 <= int_EndIndex))
                    {
                        PageOneIndexStart = int_StartIndex + int_Pos * 3;
                        PageOneIndexEnd = int_EndIndex;
                    }
                }
                else
                {
                    if ((int_Pos < PagePrintRowCount) && (int_StartIndex + int_Pos * 3 <= int_EndIndex))
                    {
                        range = xlReport.GetRange(int_StartIndex + int_Pos * 3, "A", int_EndIndex, "M");
                        range.Clear();
                    }
                }

                //因为有两个空行,设小一些

                range = xlReport.GetRange(int_EndIndex - 1, "A", int_EndIndex, "A");
                range.RowHeight = 10;

                if (pageChild > 0)
                {
                    subRange = xlReport.GetRange(47, "A", 48, "M");
                    subRange.Copy(oMissing);
                    range = xlReport.GetRange(int_EndIndex + 1, "A", int_EndIndex + 2, "M");
                    range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, oMissing, oMissing);
                }

                //客户编号：
                xlReport.SetCellText(int_EndIndex + 2, "C", dtReport.Rows[0]["Tant_CD"].ToString());

                //页数
                range = xlReport.GetRange(int_EndIndex + 1, "D", int_EndIndex + 2, "G");
                range.Merge(oMissing);
                range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;


                switch (str_Language)
                {
                    case "en":
                        xlReport.SetCellText(range, string.Format("TOTAL {0}/{1}", int_famount, int_total));
                        break;
                    case "zh-CHS":
                        xlReport.SetCellText(range, string.Format("总数 {0}/{1}", int_famount, int_total));
                        break;
                    default:
                        xlReport.SetCellText(range, string.Format("TOTAL {0}/{1}", int_famount, int_total));
                        break;
                }
                //打印次数 Pout_CT 是每生成一次Picking List M_Sys_Manager 表中的Pout_CT 加1.
                xlReport.SetCellText(int_EndIndex + 2, "M", dtReport.Rows[0]["Pout_CT"].ToString());

                Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)xlReport.Workbooks.ActiveSheet;
                ws.HPageBreaks.Add(xlReport.GetRange(baseIndex + 49, "A"));
            }
            //设第一页
            if ((PageOneIndexStart > 1) && (PageOneIndexEnd > 1))
            {
                range = xlReport.GetRange(PageOneIndexStart, "A", PageOneIndexEnd, "M");
                range.Clear();
            }

            xlReport.Print();
            xlReport.Close();
        }


        private static void P_DrawPickingListReport_Multipage_EN(ExcelAccess xlReport, DataTable dtReport, string strExcelTemplateFile)
        {

            int pageChild = 0; //当前页 Current Page
            int pageParent = 1;//总页数 Total Page
            int baseIndex = 0;
            int PageTotalRowCount = 48;// 每页打印48行,第二页从49行开始
            int PagePrintRowCount = 9;//明细每页打印9行数据 Excel 明细行为 3*9 行
            DotNetBarcode bc = new DotNetBarcode(DotNetBarcode.Types.QRCode);
            string str_Binary = "";
            string str_Date = "";
           
            //每页打印9行
        
            //根据Zone (Loca_CD 前三位来分页)

            string str_Language = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString();

            int PageOneIndexStart = 0;
            int PageOneIndexEnd = 0;

            pageParent = Convert.ToInt32(dtReport.Rows[0]["PageParent"].ToString());

            int columnIndex = 0;

            Microsoft.Office.Interop.Excel.Range range;
            Microsoft.Office.Interop.Excel.Range subRange;
            Object oMissing = System.Reflection.Missing.Value;

            int int_total = P_PickListReport_GetTotal(dtReport); ;//总数量

            DateTime Nouk_DT = DateTime.Now;

            int int_famount = 0;                 //当前页的总数量
            for (pageChild = 0; pageChild < pageParent; pageChild++)
            {
                baseIndex = pageChild * PageTotalRowCount;//每页48行 baseIndex + 1  则为当前页的起始行
                //columnIndex = pageChild * PagePrintRowCount;//每行打印9行明细记录
                //rowIndex = 1 + baseIndex;
                //复制表头
                if (pageChild != 0)
                {
                    subRange = xlReport.GetRange(1, "A", 17, "M");
                    subRange.Copy(oMissing);
                    range = xlReport.GetRange(baseIndex + 1, "A", baseIndex + 17, "M");
                    range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, oMissing, oMissing);
                    //设置行高。不知道什么原因。第一二行会变宽
                    //range = xlReport.GetRange(baseIndex + 1, "A", baseIndex + 2, "M");
                    range.RowHeight = 13.5;
                }


                //每页表头
                //生成Picking List BarCode
                QRCodeEncoder pickingNo = new QRCodeEncoder();
                pickingNo.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
                pickingNo.QRCodeScale = 2;
                pickingNo.QRCodeVersion = 7;
                pickingNo.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
                string str_Pic_No = dtReport.Rows[columnIndex]["Pic_No_Barcode"].ToString();
                Image image = pickingNo.Encode(str_Pic_No);
                string str_ImageFile = @"c:\temp.Jpeg";
                System.IO.FileStream fs = new System.IO.FileStream(str_ImageFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
                image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
                fs.Close();

                range = xlReport.GetRange(baseIndex + 3, "B", baseIndex + 7, "C");
                range.Merge(oMissing);
                xlReport.InsertPicture(baseIndex + 3, "B", baseIndex + 7, "C", str_ImageFile);//QRCode

                System.IO.File.Delete(str_ImageFile);
                //
                //Set Header
                //
                //Reprint_Flag
                range = xlReport.GetRange(baseIndex + 2, "A", baseIndex + 2, "B");
                range.Merge(oMissing);
                range.Font.Bold = true;
                //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlLineStyleNone;
                xlReport.SetCellText(baseIndex + 2, "A", baseIndex + 2, "B", dtReport.Rows[0]["RePrint_FG"].ToString());

                //打印页码
                range = xlReport.GetRange(baseIndex + 2, "J", baseIndex + 2, "K");
                range.Merge(oMissing);
                range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
                switch (str_Language)
                {
                    case "en":
                        xlReport.SetCellText(range, string.Format("PAGE {0}/{1}", pageChild + 1, pageParent));
                        break;
                    case "zh-CHS":
                        xlReport.SetCellText(range, string.Format("页数 {0}/{1}", pageChild + 1, pageParent));
                        break;
                    default:
                        xlReport.SetCellText(range, string.Format("PAGE {0}/{1}", pageChild + 1, pageParent));
                        break;
                }
                if (pageChild == 0)
                {
                    //PIC_NO
                    range = xlReport.GetRange(baseIndex + 3, "G", baseIndex + 3, "I");
                    range.Merge(oMissing);
                    xlReport.SetCellText(baseIndex + 3, "G", baseIndex + 3, "I", dtReport.Rows[0]["PIC_NO"].ToString());
                    //Delivery Date
                    //xlReport.SetCellText(baseIndex + 4, "D", "Picking Date:");
                    range = xlReport.GetRange(baseIndex + 4, "E", baseIndex + 4, "F");
                    range.Merge(oMissing);
                    range.NumberFormat = "yyyy-MM-dd";
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Siji_DT"].ToString();
                    //Promise Date
                    range = xlReport.GetRange(baseIndex + 5, "E", baseIndex + 5, "F");
                    range.Merge(oMissing);
                    range.NumberFormat = "yyyy-MM-dd";
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Nouk_DT"].ToString();

                    //Order Date 订单日期
                    //xlReport.SetCellText(baseIndex + 4, "G", "Request Date:");
                    range = xlReport.GetRange(baseIndex + 4, "H", baseIndex + 4, "I");
                    range.Merge(oMissing);
                    range.NumberFormat = "yyyy-MM-dd";
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Jytu_DT"].ToString();
                    range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                   
                    //Invoice NO
        
                    range = xlReport.GetRange(baseIndex + 5, "H", baseIndex + 5, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Cust_NO"].ToString();
                  
                    //SO NO
                 
                    range = xlReport.GetRange(baseIndex + 6, "H", baseIndex + 6, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Jyht_NO"].ToString();
              
                    //CPO NO
                    //xlReport.SetCellText(baseIndex + 7, "G", "Customer PO:");
                    range = xlReport.GetRange(baseIndex + 7, "H", baseIndex + 7, "M");
                    range.Merge(oMissing);
                    range.NumberFormat = "@";
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Ktyu_NO"].ToString();
                   
                    //POS COUNT 显示明细有多少行
                    xlReport.SetCellText(baseIndex + 5, "J", dtReport.Rows.Count.ToString());
                    xlReport.SetCellText(baseIndex + 5, "K", "POS");
                    //Print Date
                    range = xlReport.GetRange(baseIndex + 3, "L", baseIndex + 3, "M");
                    range.Merge(oMissing);
                    range.NumberFormat = "yyyy-MM-dd";
                    xlReport.SetCellText(baseIndex + 3, "L", baseIndex + 3, "M", DateTime.Now.ToString("yyyy-MM-dd"));
                    //Print Time
                    range = xlReport.GetRange(baseIndex + 4, "L", baseIndex + 4, "M");
                    range.Merge(oMissing);
                    range.NumberFormat = "HH:mm:ss";
                    xlReport.SetCellText(baseIndex + 4, "L", baseIndex + 4, "M", DateTime.Now.ToString("HH:mm:ss"));

                    //仓库
                    //range = xlReport.GetRange(baseIndex + 6, "J", baseIndex + 6, "K");
                    //range.Merge(oMissing);
                    //xlReport.SetCellText(range, "WAREHOUSE:");

                    range = xlReport.GetRange(baseIndex + 6, "L", baseIndex + 6, "M");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Souk_NM"].ToString();
                    //// 是否所有POS 已扣减

                    range = xlReport.GetRange(baseIndex + 8, "M", baseIndex + 9, "M");
                    range.Merge(oMissing);
                    range.Font.Size = 16;
                    range.Font.Bold = true;
                    xlReport.SetCellText(baseIndex + 8, "M", baseIndex + 9, "M", dtReport.Rows[0]["Fin_Msg"].ToString());

                    //画直线
                    //range = xlReport.GetRange(baseIndex + 8, "A", baseIndex + 8, "I");
                    //range.Merge(oMissing);
                    //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;
                    //发货方Destion Information
                    //Name
                    //range = xlReport.GetRange(baseIndex + 9, "A", baseIndex + 9, "B");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 9, "A", baseIndex + 9, "B", "TO:");
                    range = xlReport.GetRange(baseIndex + 9, "C", baseIndex + 9, "I");
                    range.Merge(oMissing);
                    range.Font.Bold = true;
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Todo_NM"].ToString();
    
                    //Address
                    //range = xlReport.GetRange(baseIndex + 10, "A", baseIndex + 10, "B");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 10, "A", baseIndex + 10, "B", "ADDRESS:");
                    range = xlReport.GetRange(baseIndex + 10, "C", baseIndex + 10, "M");
                    range.Merge(oMissing);
                    range.Font.Bold = true;
                    string str_Todo_AD = dtReport.Rows[0]["Todo_AD"].ToString();
                    string str_TdZip_NO = dtReport.Rows[0]["TdZip_NO"].ToString();
                    if (str_TdZip_NO.Length > 0)
                    {
                        str_Todo_AD = dtReport.Rows[0]["TdZip_NO"].ToString() + " " + str_Todo_AD;
                    }
                    range.Cells.FormulaR1C1 = str_Todo_AD;
 
                    //Telphone
                    //range = xlReport.GetRange(baseIndex + 11, "A", baseIndex + 11, "B");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 11, "A", baseIndex + 11, "B", "TEL:");
                    range = xlReport.GetRange(baseIndex + 11, "C", baseIndex + 11, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["TdTel_NO"].ToString();
                 
                    ////画直线
                    //range = xlReport.GetRange(baseIndex + 11, "A", baseIndex + 11, "I");
                    //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;

                    //收货方 Order Customer Information
                    //Order Customer Name
                    //range = xlReport.GetRange(baseIndex + 12, "A", baseIndex + 12, "B");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 12, "A", baseIndex + 12, "B", "CUSTOMER:");
                    range = xlReport.GetRange(baseIndex + 12, "C", baseIndex + 12, "I");
                    range.Merge(oMissing);
                    range.Font.Bold = true;
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Toku_NM"].ToString();
                    //Address
                    //range = xlReport.GetRange(baseIndex + 13, "A", baseIndex + 13, "B");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 13, "A", baseIndex + 13, "B", "DD:");
                    range = xlReport.GetRange(baseIndex + 13, "C", baseIndex + 13, "M");
                    range.Merge(oMissing);
                    range.Font.Bold = true;
                    string str_Toku_AD = dtReport.Rows[0]["Toku_AD"].ToString();
                    string str_Toku_Zip_NO = dtReport.Rows[0]["Toku_Zip_NO"].ToString();
                    //string str_Toku_Zip_NO = "";
                    if (str_Toku_Zip_NO.Length > 0)
                    {
                        str_Toku_AD = str_Toku_Zip_NO + " " + str_Toku_AD;
                    }
                    range.Cells.FormulaR1C1 = str_Toku_AD;
                    //Telphone
                    //range = xlReport.GetRange(baseIndex + 14, "A", baseIndex + 14, "B");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 14, "A", baseIndex + 14, "B", "TEL:");
                    range = xlReport.GetRange(baseIndex + 14, "C", baseIndex + 14, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Toku_Tel_NO"].ToString();
                
                    //画直线
                    //range = xlReport.GetRange(baseIndex + 14, "A", baseIndex + 14, "I");
                    //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;

                    //其它信息
                    //运费

                    //交货条件
                    //range = xlReport.GetRange(baseIndex + 15, "F", baseIndex + 15, "G");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(range, "SHIPPING MARK:");

                    range = xlReport.GetRange(baseIndex + 15, "H", baseIndex + 15, "K");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Bik_03_TXT"].ToString();
                  
                    //运送方式 应会改
       
                    //range = xlReport.GetRange(baseIndex + 15, "A", baseIndex + 15, "B");
                    //range.Merge(oMissing);
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 15, "A", baseIndex + 15, "B", "D.METHOD:");
                    range = xlReport.GetRange(baseIndex + 15, "C", baseIndex + 15, "D");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 =  dtReport.Rows[0]["unso_CD"].ToString() + "    " + dtReport.Rows[0]["unso_NM"].ToString();


                    //备注
                    //range = xlReport.GetRange(baseIndex + 16, "A", baseIndex + 16, "B");
                    //range.Merge(oMissing);
                    //range.WrapText = true;
                    //range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    //xlReport.SetCellText(baseIndex + 16, "A", baseIndex + 16, "B", "REMARK:");
                    range = xlReport.GetRange(baseIndex + 16, "C", baseIndex + 17, "M");
                    range.Merge(oMissing);
                    range.WrapText = true;
                    range.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignTop;
                    range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Bik_01_TXT"].ToString();
   

                    string Zone_Text = P_Get_Zone_Text(dtReport);
                    //Zone_Text
                    range = xlReport.GetRange(baseIndex + 14, "J", baseIndex + 14, "L");
                    range.Merge(oMissing);
                    xlReport.SetCellText(baseIndex + 14, "J", baseIndex + 14, "L", Zone_Text);
                    //Konp_NM 包装区分
                    //xlReport.SetCellText(baseIndex + 14, "M", dtReport.Rows[0]["Konp_NM"].ToString());
                    if (dtReport.Rows[0]["Konp_NM"].ToString().Length > 0)
                    {
                        xlReport.SetCellText(baseIndex + 14, "M", "Packing");
                    }
                    else
                    {
                        xlReport.SetCellText(baseIndex + 14, "M", "");
                    }

                    //画直线
                    //range = xlReport.GetRange(baseIndex + 17, "A", baseIndex + 17, "M");
                    //range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick;

                }
             
                //每页明细
                int x = 0;
                int int_StartIndex = 18 + baseIndex;
                int int_EndIndex = 18 + baseIndex + 28;
                ////设置明细行高
                range = xlReport.GetRange(int_StartIndex, "A", int_EndIndex - 1, "A");
                range.RowHeight = 19.5;
                int_famount = 0;

                int int_Pos = 0;
                string[,] detailArray = new string[28, 12];
                int xx = 0;
                //复制明细格式
                if (pageChild != 0)
                {
                    subRange = xlReport.GetRange(18, "A", 46, "M");
                    subRange.Copy(oMissing);
                    range = xlReport.GetRange(int_StartIndex, "A", int_EndIndex, "M");
                    range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteFormats, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, oMissing, oMissing);
                }
                for (int j = columnIndex; (j < columnIndex + 9) && (j < dtReport.Rows.Count) && (Convert.ToInt32(dtReport.Rows[columnIndex]["PageChild"].ToString()) == pageChild + 1); j++)
                {

                    int RowIndex = 18 + x * 3 + baseIndex;

                    xx = 3 * x;

                    detailArray[xx, 1] = dtReport.Rows[j]["Loca_CD"].ToString();//Location
                    detailArray[xx, 3] = dtReport.Rows[j]["Jyot_NM"].ToString();//Condtion
                    detailArray[xx, 4] = dtReport.Rows[j]["Cust_Shoh_NM"].ToString();//Vender Name

                    detailArray[xx + 1, 0] = dtReport.Rows[j]["Shoh_CD"].ToString();//Product CODE
                    switch (str_Language)
                    {
                        case "en":
                            detailArray[xx + 1, 4] = dtReport.Rows[j]["Lot_CD"].ToString();//Lot No
                            break;
                        default:
                            detailArray[xx + 1, 3] = dtReport.Rows[j]["Lot_CD"].ToString();//Lot No
                            break;
                    }
                    detailArray[xx + 2, 0] = dtReport.Rows[j]["Shoh_NM"].ToString();//Product NAME

                    detailArray[xx, 6] = dtReport.Rows[j]["Yote_QT"].ToString();
                    detailArray[xx, 7] = dtReport.Rows[j]["Tani_NM"].ToString();

                    detailArray[xx, 8] = "MOQ:";
                    //Add by Michael Date:2009-06-16 start
                    detailArray[xx + 1, 8] = dtReport.Rows[j]["Cust_PO"].ToString();
                    //Add by Michael Date:2009-06-16 end
                    detailArray[xx, 9] = dtReport.Rows[j]["Iri_QT"].ToString();
                    float Disp_WT = default(float);
                    if (float.TryParse(dtReport.Rows[j]["Disp_WT"].ToString(), out Disp_WT))
                    {
                        detailArray[xx + 2, 8] = Disp_WT.ToString();
                    }
                    else
                    {
                        detailArray[xx + 2, 8] = dtReport.Rows[j]["Disp_WT"].ToString();
                    }

                    detailArray[xx + 2, 9] = "B.QT:";
                    detailArray[xx + 2, 10] = dtReport.Rows[j]["Hako_QT"].ToString();
                    detailArray[xx + 2, 11] = string.Format("Frctn:{0}", dtReport.Rows[j]["Ha_QT"].ToString().Trim());

                    int_famount = int_famount + Convert.ToInt32(dtReport.Rows[j]["Yote_QT"].ToString());

                    //QRCodeEncoder product = new QRCodeEncoder();
                    //product.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
                    //product.QRCodeScale = 2;
                    //product.QRCodeVersion = 7;
                    //product.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;

                    //image = product.Encode("ProductNo" + dtReport.Rows[j]["Shoh_CD"].ToString());
                    //System.IO.FileStream fs1 = new System.IO.FileStream(str_ImageFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
                    //image.Save(fs1, System.Drawing.Imaging.ImageFormat.Jpeg);
                    //fs1.Close();

                    if (DateTime.TryParse(dtReport.Rows[0]["Nyuk_DT"].ToString(), out Nouk_DT))
                    {
                        str_Date = Nouk_DT.ToString("yyyyMMdd");
                    }
                    else
                    {
                        str_Date = DateTime.Now.ToString("yyyyMMdd");
                    }

                    if (G_CommonDefine.G_str_Customer_CD != "FESH")
                    {
                        //改成Carton Label
                        str_Binary = "N" + SetLenth("100000001", 20) + //FB_NO
                                         SetLenth("1", 5) +            //FBPOS_NO 
                                         SetLenth("1", 5) +             //SEQ_NO
                                         SetLenth(G_CommonDefine.G_str_Customer_CD, 15) +
                                         SetLenth(dtReport.Rows[j]["Shoh_CD"].ToString(), 80) +
                                         SetLenth(dtReport.Rows[j]["Lot_CD"].ToString(), 50) +
                                         SetLenth("10", 2) +
                                         SetLenth(dtReport.Rows[j]["Yote_QT"].ToString(), 5) +
                                         SetLenth(str_Date, 8);
                    }
                    else
                    {
                        str_Binary = "ProductNo" + dtReport.Rows[j]["Shoh_CD"].ToString();
                    }

                    bc.Save(str_Binary, str_ImageFile, 200, 200);

                    range = xlReport.GetRange(RowIndex, "M", RowIndex + 2, "M");
    
                    xlReport.InsertPictureBmp(RowIndex, "M", RowIndex + 2, "M", str_ImageFile);

                    System.IO.File.Delete(str_ImageFile);

                    range = xlReport.GetRange(RowIndex, "A", RowIndex + 2, "M");
                    xlReport.SetBordersEdge(range, BordersEdge.xlBottom);

                    x = x + 1;//下一下行数据
                    columnIndex++;

                    int_Pos++; //当前页有多少行
                }
                //页尾
                //设置页尾
                //Operator

                range = xlReport.GetRange(int_StartIndex, "A", int_EndIndex -1, "L");
                range.Value2 = detailArray;

                //最后一页
                if (pageChild == 0)
                {

                    if ((int_Pos < PagePrintRowCount) && (int_StartIndex + int_Pos * 3 <= int_EndIndex))
                    {
                        PageOneIndexStart = int_StartIndex + int_Pos * 3;
                        PageOneIndexEnd = int_EndIndex;
                    }
                }
                else
                {
                    if ((int_Pos < PagePrintRowCount) && (int_StartIndex + int_Pos * 3 <= int_EndIndex))
                    {
                        range = xlReport.GetRange(int_StartIndex + int_Pos * 3, "A", int_EndIndex, "M");
                        range.Clear();
                    }
                }

                //因为有两个空行,设小一些

                range = xlReport.GetRange(int_EndIndex - 1, "A", int_EndIndex, "A");
                range.RowHeight = 10;

                if (pageChild > 0)
                {
                    subRange = xlReport.GetRange(47, "A", 48, "M");
                    subRange.Copy(oMissing);
                    range = xlReport.GetRange(int_EndIndex + 1, "A", int_EndIndex + 2, "M");
                    range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, oMissing, oMissing);
                }

                //客户编号：
                xlReport.SetCellText(int_EndIndex + 2, "C", dtReport.Rows[0]["Tant_CD"].ToString());

                //页数
                range = xlReport.GetRange(int_EndIndex + 1, "D", int_EndIndex + 2, "G");
                range.Merge(oMissing);
                range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
                
               
                switch (str_Language)
                {
                    case "en":
                        xlReport.SetCellText(range, string.Format("TOTAL {0}/{1}", int_famount, int_total));
                        break;
                    case "zh-CHS":
                        xlReport.SetCellText(range, string.Format("总数 {0}/{1}", int_famount, int_total));
                        break;
                    default:
                        xlReport.SetCellText(range, string.Format("TOTAL {0}/{1}", int_famount, int_total));
                        break;
                }
                //打印次数 Pout_CT 是每生成一次Picking List M_Sys_Manager 表中的Pout_CT 加1.
                xlReport.SetCellText(int_EndIndex + 2, "M", dtReport.Rows[0]["Pout_CT"].ToString());

                Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)xlReport.Workbooks.ActiveSheet;
                ws.HPageBreaks.Add(xlReport.GetRange(baseIndex + 49, "A"));
            }
            //设第一页
            if ((PageOneIndexStart > 1) && (PageOneIndexEnd > 1))
            {
                range = xlReport.GetRange(PageOneIndexStart, "A", PageOneIndexEnd, "M");
                range.Clear();
            }

            xlReport.Print();
            xlReport.Close();
        }

        private static void P_DrawPickingListReport_Multipage_EN_ForExport(ExcelAccess xlReport, DataTable dtReport, string strExcelTemplateFile)
        {

            int pageChild = 0; //当前页 Current Page
            int pageParent = 1;//总页数 Total Page
            int baseIndex = 0;
            int PageTotalRowCount = 48;// 每页打印48行,第二页从49行开始
            int PagePrintRowCount = 9;//明细每页打印9行数据 Excel 明细行为 3*9 行
            DotNetBarcode bc = new DotNetBarcode(DotNetBarcode.Types.QRCode);
            string str_Binary = "";
            string str_Date = "";
            //每页打印9行
            pageParent = dtReport.Rows.Count / PagePrintRowCount;
            if ((dtReport.Rows.Count % PagePrintRowCount) != 0)
            {
                pageParent += 1;
            }

            int PageOneIndexStart = 0;
            int PageOneIndexEnd = 0;

            int columnIndex = 0;

            Microsoft.Office.Interop.Excel.Range range;
            Microsoft.Office.Interop.Excel.Range subRange;
            Object oMissing = System.Reflection.Missing.Value;
            Image image;
            string str_ImageFile = string.Empty;
            str_ImageFile = @"c:\temp.Jpeg";
            string str_PIC_NO = dtReport.Rows[0]["PIC_NO"].ToString();

            int int_total = P_PickListReport_GetTotal(dtReport); ;//总数量

            DateTime Nouk_DT = DateTime.Now;

            int int_famount = 0;                 //当前页的总数量
            for (pageChild = 0; pageChild < pageParent; pageChild++)
            {
                baseIndex = pageChild * PageTotalRowCount;//每页48行 baseIndex + 1  则为当前页的起始行
                //columnIndex = pageChild * PagePrintRowCount;//每行打印9行明细记录
                //rowIndex = 1 + baseIndex;
                //复制表头
                if (pageChild != 0)
                {
                    subRange = xlReport.GetRange(1, "A", 17, "M");
                    subRange.Copy(oMissing);
                    range = xlReport.GetRange(baseIndex + 1, "A", baseIndex + 17, "M");
                    range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, oMissing, oMissing);
                    //设置行高。不知道什么原因。第一二行会变宽
                    //range = xlReport.GetRange(baseIndex + 1, "A", baseIndex + 2, "M");
                    range.RowHeight = 13.5;
                }
                range = xlReport.GetRange(baseIndex + 2, "A");
                range.Cells.FormulaR1C1 = dtReport.Rows[0]["RePrint_FG"].ToString();
               

                //打印页码
                range = xlReport.GetRange(baseIndex + 2, "J");
                range.Cells.FormulaR1C1 = string.Format("PAGE {0}/{1}", pageChild + 1, pageParent);

                if (pageChild == 0)
                {
                    //PIC_NO
                    range = xlReport.GetRange(baseIndex + 3, "G");
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["PIC_NO"].ToString();
                 
                    //Delivery Date
                    range = xlReport.GetRange(baseIndex + 4, "E", baseIndex + 4, "F");
                    range.Merge(oMissing);
                    range.NumberFormat = "yyyy-MM-dd";
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Siji_DT"].ToString();
                 
                    //Promise Date
                    range = xlReport.GetRange(baseIndex + 5, "E", baseIndex + 5, "F");
                    range.Merge(oMissing);
                    range.NumberFormat = "yyyy-MM-dd";
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Nouk_DT"].ToString();

                    

                    //Request Date:订单日期
                    range = xlReport.GetRange(baseIndex + 4, "H", baseIndex + 4, "I");
                    range.Merge(oMissing);
                    range.NumberFormat = "yyyy-MM-dd";
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Jytu_DT"].ToString();

                    //D/N NO:
                    range = xlReport.GetRange(baseIndex + 5, "H", baseIndex + 5, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Cust_NO"].ToString();
                   
                    //Contract No:
                    range = xlReport.GetRange(baseIndex + 6, "H", baseIndex + 6, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Jyht_NO"].ToString();

                    //Customer PO:
                    range = xlReport.GetRange(baseIndex + 7, "H", baseIndex + 7, "M");
                    range.Merge(oMissing);      
                    range.NumberFormat = "@";
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Ktyu_NO"].ToString();
 
                    //POS COUNT 显示明细有多少行
                    xlReport.SetCellText(baseIndex + 5, "J", dtReport.Rows.Count.ToString());
                    xlReport.SetCellText(baseIndex + 5, "K", "POS");
                    //Print Date
                    range = xlReport.GetRange(baseIndex + 3, "L", baseIndex + 3, "M");
                    range.Merge(oMissing);
                    range.NumberFormat = "yyyy-MM-dd";
                    xlReport.SetCellText(baseIndex + 3, "L", baseIndex + 3, "M", DateTime.Now.ToString("yyyy-MM-dd"));
                    //Print Time
                    range = xlReport.GetRange(baseIndex + 4, "L", baseIndex + 4, "M");
                    range.Merge(oMissing);
                    range.NumberFormat = "HH:mm:ss";
                    xlReport.SetCellText(baseIndex + 4, "L", baseIndex + 4, "M", DateTime.Now.ToString("HH:mm:ss"));

                    //仓库
                    range = xlReport.GetRange(baseIndex + 6, "J", baseIndex + 6, "K");
                    range.Merge(oMissing);
                    xlReport.SetCellText(range, "WAREHOUSE:");

                    range = xlReport.GetRange(baseIndex + 6, "L", baseIndex + 6, "M");
                    range.Merge(oMissing);
                    range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                    xlReport.SetCellText(range, dtReport.Rows[0]["Souk_NM"].ToString());

                    //// 是否所有POS 已扣减
                    range = xlReport.GetRange(baseIndex + 8, "M", baseIndex + 9, "M");
                    range.Merge(oMissing);
                    xlReport.SetCellText(baseIndex + 8, "M", baseIndex + 9, "M", dtReport.Rows[0]["Fin_Msg"].ToString());

                    //画直线
                    range = xlReport.GetRange(baseIndex + 8, "A", baseIndex + 8, "I");
                    range.Merge(oMissing);
                    range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;
                    //发货方Destion Information
                    //Name
                    range = xlReport.GetRange(baseIndex + 9, "A", baseIndex + 9, "B");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = "TO:";
                    range = xlReport.GetRange(baseIndex + 9, "C", baseIndex + 9, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Todo_NM"].ToString();

                    //Address
                    range = xlReport.GetRange(baseIndex + 10, "A", baseIndex + 10, "B");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = "ADDRESS:";
                    range = xlReport.GetRange(baseIndex + 10, "C", baseIndex + 10, "M");
                    range.Merge(oMissing);
                   
                    string str_Todo_AD = dtReport.Rows[0]["Todo_AD"].ToString();
                    string str_TdZip_NO = dtReport.Rows[0]["TdZip_NO"].ToString();
                    if (str_TdZip_NO.Length > 0)
                    {
                        str_Todo_AD = dtReport.Rows[0]["TdZip_NO"].ToString() + " " + str_Todo_AD;
                    }
                    range.Cells.FormulaR1C1 = str_Todo_AD;
                    //Telphone
                    range = xlReport.GetRange(baseIndex + 11, "A", baseIndex + 11, "B");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = "TEL:";

                    range = xlReport.GetRange(baseIndex + 11, "C", baseIndex + 11, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["TdTel_NO"].ToString();
                 
                    //画直线
                    range = xlReport.GetRange(baseIndex + 11, "A", baseIndex + 11, "I");
                    range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;

                    //收货方 Order Customer Information
                    //Order Customer Name
                    range = xlReport.GetRange(baseIndex + 12, "A", baseIndex + 12, "B");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = "CUSTOMER:";
        
                    range = xlReport.GetRange(baseIndex + 12, "C", baseIndex + 12, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Toku_NM"].ToString();
                  
                    //Address
                    range = xlReport.GetRange(baseIndex + 13, "A", baseIndex + 13, "B");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = "DD:";

                    range = xlReport.GetRange(baseIndex + 13, "C", baseIndex + 13, "I");
                    range.Merge(oMissing);
                   
                    string str_Toku_AD = dtReport.Rows[0]["Toku_AD"].ToString();
                    string str_Toku_Zip_NO = dtReport.Rows[0]["Toku_Zip_NO"].ToString();
                    if (str_Toku_Zip_NO.Length > 0)
                    {
                        str_Toku_AD = str_Toku_Zip_NO + " " + str_Toku_AD;
                    }
                    range.Cells.FormulaR1C1 = str_Toku_AD;

                    //Telphone
                    range = xlReport.GetRange(baseIndex + 14, "A", baseIndex + 14, "B");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = "TEL:";

                    range = xlReport.GetRange(baseIndex + 14, "C", baseIndex + 14, "I");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Toku_Tel_NO"].ToString();

                    //画直线
                    range = xlReport.GetRange(baseIndex + 14, "A", baseIndex + 14, "I");
                    range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin;

                    //其它信息
                    //运费

                    //交货条件
                    range = xlReport.GetRange(baseIndex + 15, "F", baseIndex + 15, "G");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = "SHIPPING MARK:";


                    range = xlReport.GetRange(baseIndex + 15, "H", baseIndex + 15, "K");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Bik_03_TXT"].ToString();

                    //运送方式 应会改

                    range = xlReport.GetRange(baseIndex + 15, "A", baseIndex + 15, "B");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = "D.METHOD:";

                    range = xlReport.GetRange(baseIndex + 15, "C", baseIndex + 15, "D");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["unso_CD"].ToString() + "    " + dtReport.Rows[0]["unso_NM"].ToString();
                  

                    //备注
                    range = xlReport.GetRange(baseIndex + 16, "A", baseIndex + 16, "B");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = "REMARK:";
                    
                    range = xlReport.GetRange(baseIndex + 16, "C", baseIndex + 17, "M");
                    range.Merge(oMissing);
                    range.WrapText = true;
                    range.Cells.FormulaR1C1 = dtReport.Rows[0]["Bik_01_TXT"].ToString();

                   

                    string Zone_Text = P_Get_Zone_Text(dtReport);
                    //Zone_Text
                    range = xlReport.GetRange(baseIndex + 14, "J", baseIndex + 14, "L");
                    range.Merge(oMissing);
                    range.Cells.FormulaR1C1 = Zone_Text;
                    //Konp_NM 包装区分
                    //xlReport.SetCellText(baseIndex + 14, "M", dtReport.Rows[0]["Konp_NM"].ToString());
                    if (dtReport.Rows[0]["Konp_NM"].ToString().Length > 0)
                    {
                        xlReport.SetCellText(baseIndex + 14, "M", "Packing");
                    }
                    else
                    {
                        xlReport.SetCellText(baseIndex + 14, "M", "");
                    }

                    //画直线
                    range = xlReport.GetRange(baseIndex + 17, "A", baseIndex + 17, "M");
                    range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick;

                }

                //每页明细
                int x = 0;
                int int_StartIndex = 18 + baseIndex;
                int int_EndIndex = 18 + baseIndex + 28;
                ////设置明细行高
                range = xlReport.GetRange(int_StartIndex, "A", int_EndIndex - 1, "A");
                range.RowHeight = 19.5;
                int_famount = 0;

                int int_Pos = 0;
                string[,] detailArray = new string[28, 12];
                int xx = 0;
                //复制明细格式
                if (pageChild != 0)
                {
                    subRange = xlReport.GetRange(18, "A", 46, "M");
                    subRange.Copy(oMissing);
                    range = xlReport.GetRange(int_StartIndex, "A", int_EndIndex, "M");
                    range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteFormats, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, oMissing, oMissing);
                }
                int yy = 0;//最多九行

                string MIN_POS_NO = string.Empty;
                string MAX_POS_NO = string.Empty;

                for (int j = columnIndex; (yy < 9) && (j < dtReport.Rows.Count); j++)
                {

                    int RowIndex = 18 + x * 3 + baseIndex;

                    xx = 3 * x;

                    detailArray[xx, 1] = dtReport.Rows[j]["Loca_CD"].ToString();//Location
                    detailArray[xx, 3] = dtReport.Rows[j]["Jyot_NM"].ToString();//Condtion
                    detailArray[xx, 4] = dtReport.Rows[j]["Cust_Shoh_NM"].ToString();//Vender Name

                    detailArray[xx + 1, 0] = dtReport.Rows[j]["Shoh_CD"].ToString();//Product CODE
                    detailArray[xx + 1, 3] = dtReport.Rows[j]["Lot_CD"].ToString();//Lot No
                    detailArray[xx + 2, 0] = dtReport.Rows[j]["Shoh_NM"].ToString();//Product NAME

                    detailArray[xx, 6] = dtReport.Rows[j]["Yote_QT"].ToString();
                    detailArray[xx, 7] = dtReport.Rows[j]["Tani_NM"].ToString();

                    detailArray[xx, 8] = "MOQ:";
                    //Add by Michael Date:2009-06-16 start
                    detailArray[xx + 1, 8] = dtReport.Rows[j]["Cust_PO"].ToString();
                    //Add by Michael Date:2009-06-16 end
                    detailArray[xx, 9] = dtReport.Rows[j]["Iri_QT"].ToString();
                    float Disp_WT = default(float);
                    if (float.TryParse(dtReport.Rows[j]["Disp_WT"].ToString(), out Disp_WT))
                    {
                        detailArray[xx + 2, 8] = Disp_WT.ToString();
                    }
                    else
                    {
                        detailArray[xx + 2, 8] = dtReport.Rows[j]["Disp_WT"].ToString();
                    }

                    detailArray[xx + 2, 9] = "B.QT:";
                    detailArray[xx + 2, 10] = dtReport.Rows[j]["Hako_QT"].ToString();
                    detailArray[xx + 2, 11] = string.Format("Frctn:{0}", dtReport.Rows[j]["Ha_QT"].ToString().Trim());

                    int_famount = int_famount + Convert.ToInt32(dtReport.Rows[j]["Yote_QT"].ToString());

                    if (yy == 0)
                    {
                        MIN_POS_NO = dtReport.Rows[j]["PicPOS_NO"].ToString();
                    }
                    MAX_POS_NO = dtReport.Rows[j]["PicPOS_NO"].ToString();

                    //QRCodeEncoder product = new QRCodeEncoder();
                    //product.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
                    //product.QRCodeScale = 2;
                    //product.QRCodeVersion = 7;
                    //product.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
                    //str_ImageFile = @"c:\temp.Jpeg";
                    //image = product.Encode("ProductNo" + dtReport.Rows[j]["Shoh_CD"].ToString());
                    //System.IO.FileStream fs1 = new System.IO.FileStream(str_ImageFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
                    //image.Save(fs1, System.Drawing.Imaging.ImageFormat.Jpeg);
                    //fs1.Close();

                    if (G_CommonDefine.G_str_Customer_CD != "FESH")
                    {
                        //改成Carton Label
                        str_Binary = "N" + SetLenth("100000001", 20) + //FB_NO
                                         SetLenth("1", 5) +            //FBPOS_NO 
                                         SetLenth("1", 5) +             //SEQ_NO
                                         SetLenth(G_CommonDefine.G_str_Customer_CD, 15) +
                                         SetLenth(dtReport.Rows[j]["Shoh_CD"].ToString(), 80) +
                                         SetLenth(dtReport.Rows[j]["Lot_CD"].ToString(), 50) +
                                         SetLenth("10", 2) +
                                         SetLenth(dtReport.Rows[j]["Yote_QT"].ToString(), 5) +
                                         SetLenth(str_Date, 8);
                    }
                    else
                    {
                        str_Binary = "ProductNo" + dtReport.Rows[j]["Shoh_CD"].ToString();
                    }

                    bc.Save(str_Binary, str_ImageFile, 200, 200);

                    range = xlReport.GetRange(RowIndex, "M", RowIndex + 2, "M");

                    xlReport.InsertPictureBmp(RowIndex, "M", RowIndex + 2, "M", str_ImageFile);

                    System.IO.File.Delete(str_ImageFile);

                    range = xlReport.GetRange(RowIndex, "A", RowIndex + 2, "M");
                    xlReport.SetBordersEdge(range, BordersEdge.xlBottom);

                    x = x + 1;//下一下行数据
                    columnIndex++;
                    yy++;
                    int_Pos++; //当前页有多少行

                }
                //页尾
                //设置页尾
                //Operator

                range = xlReport.GetRange(int_StartIndex, "A", int_EndIndex - 1, "L");
                range.Value2 = detailArray;

                //最后一页
                if (pageChild == 0)
                {

                    if ((int_Pos < PagePrintRowCount) && (int_StartIndex + int_Pos * 3 <= int_EndIndex))
                    {
                        PageOneIndexStart = int_StartIndex + int_Pos * 3;
                        PageOneIndexEnd = int_EndIndex;
                    }
                }
                else
                {
                    if ((int_Pos < PagePrintRowCount) && (int_StartIndex + int_Pos * 3 <= int_EndIndex))
                    {
                        range = xlReport.GetRange(int_StartIndex + int_Pos * 3, "A", int_EndIndex, "M");
                        range.Clear();
                    }
                }

                //因为有两个空行,设小一些

                range = xlReport.GetRange(int_EndIndex - 1, "A", int_EndIndex, "A");
                range.RowHeight = 10;

                if (pageChild > 0)
                {
                    subRange = xlReport.GetRange(47, "A", 48, "M");
                    subRange.Copy(oMissing);
                    range = xlReport.GetRange(int_EndIndex + 1, "A", int_EndIndex + 2, "M");
                    range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, oMissing, oMissing);
                }

                //客户编号：
                xlReport.SetCellText(int_EndIndex + 2, "C", dtReport.Rows[0]["Tant_CD"].ToString());

                //页数
                range = xlReport.GetRange(int_EndIndex + 1, "D", int_EndIndex + 2, "G");
                range.Merge(oMissing);
                range.Cells.FormulaR1C1 = string.Format("TOTAL {0}/{1}", int_famount, int_total);

                xlReport.SetCellText(int_EndIndex + 2, "M", dtReport.Rows[0]["Pout_CT"].ToString());

                //打印QRCode
                //生成Picking List BarCode
                QRCodeEncoder pickingNo = new QRCodeEncoder();
                pickingNo.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
                pickingNo.QRCodeScale = 2;
                pickingNo.QRCodeVersion = 7;
                pickingNo.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;


                string str_Pic_No_Barcode = str_PIC_NO + MIN_POS_NO.PadLeft(3, '0') + MAX_POS_NO.PadLeft(3, '0');

                image = pickingNo.Encode(str_Pic_No_Barcode);
                str_ImageFile = @"c:\temp.Jpeg";
                System.IO.FileStream fs = new System.IO.FileStream(str_ImageFile, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
                image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
                fs.Close();

                range = xlReport.GetRange(baseIndex + 3, "B", baseIndex + 7, "C");
                range.Merge(oMissing);
                xlReport.InsertPicture(baseIndex + 3, "B", baseIndex + 7, "C", str_ImageFile);//QRCode

                System.IO.File.Delete(str_ImageFile);

                Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)xlReport.Workbooks.ActiveSheet;
                ws.HPageBreaks.Add(xlReport.GetRange(baseIndex + 49, "A"));
            }
            //设第一页
            if ((PageOneIndexStart > 1) && (PageOneIndexEnd > 1))
            {
                range = xlReport.GetRange(PageOneIndexStart, "A", PageOneIndexEnd, "M");
                range.Clear();
            }
            //保存Excel
            //string str_Title = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Please_Set_Dest);
            //string str_InitialDir = @G_CommonClassSystem.G_System_GetDeskTopPath().ToString();

            //string str_InitialFile = "Actual Delivery List";

            //string str_Filter = "(*.xls)|*.xls";

            //string str_FilePath = G_CommonClassControl.G_Control_saveFileDialog(str_Title, str_InitialDir, str_InitialFile, str_Filter);
            string str_InitialFile = @G_CommonClassSystem.G_System_GetDeskTopPath().ToString() + @"\Actual Delivery List_" + DateTime.Now.ToString("yyyyMMdd");

            if (!System.IO.Directory.Exists(str_InitialFile))
            {
                System.IO.Directory.CreateDirectory(str_InitialFile);
            }

            string str_FilePath = str_InitialFile  + @"\" + str_PIC_NO + "_" + DateTime.Now.ToString("HHmmss") + ".xls";

            xlReport.SaveAs(str_FilePath, true);
            xlReport.Close();
        }



        public static void PickingListReportForExport(DataTable dt)
        {
            string str_Message, str_Caption;
            int int_PrintCount = dt.Rows.Count;

            for (int i = 0; i < int_PrintCount; i++)
            {
                string str_Print_Pic_No = dt.Rows[i]["Pic_No"].ToString();

                bool isEnblishVersion = false;
                ExcelAccess xlReport = new ExcelAccess();
                string strPath = Application.StartupPath + @"\Report";

                string strExcelTemplateFile = System.IO.Path.GetFullPath(strPath + @"\PickingListEN.xlt");
                string str_Language = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString();

                if (!System.IO.File.Exists(strExcelTemplateFile))
                {
                    str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Excel_Template_NoExists);
                    str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                    MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                DataTable dtReport = G_F_Mortgage_PrintPickingList_GetData(str_Print_Pic_No, G_CommonDefine.G_PCNM);

                if ((dtReport == null) || (dtReport.Rows.Count == 0))
                {
                    return;
                }


                xlReport.Open(strExcelTemplateFile);
                xlReport.IsVisibledExcel = true;


                P_DrawPickingListReport_Multipage_EN_ForExport(xlReport, dtReport, strExcelTemplateFile);
            }
        }


        /// <summary>
        /// Retrun Zone Text
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        private static string P_Get_Zone_Text(DataTable dtReport)
        {
            //ZNOE_Text 重新计算ZNOE_Text  分组统计 Loca_CD 前三位相同的行数
            Hashtable hash = new Hashtable();
            System.Text.StringBuilder text = new StringBuilder();
            for (int j = 0; j < dtReport.Rows.Count; j++)
            {
                string Loca_CD = dtReport.Rows[j]["Loca_CD"].ToString();
                if (Loca_CD.Length > 0)
                {
                    Loca_CD = Loca_CD.Substring(0, 3);
                    if (hash.ContainsKey(Loca_CD))
                    {
                        hash[Loca_CD] = Convert.ToInt32(hash[Loca_CD]) + 1;
                    }
                    else
                    {
                        hash[Loca_CD] = 1;
                    }
                }
            }
            foreach (System.Collections.DictionaryEntry value in hash)
            {
                string str_Zone = value.Key.ToString() + "*" + value.Value.ToString();
                if (text.ToString().Length > 0)
                {
                    text.Append("   ");
                }
                text.Append(str_Zone);
            }
            return text.ToString();
        }

        /// <summary>
        /// 统计 Picking List Report Quantity
        /// </summary>
        /// <param name="dtReport"></param>
        /// <returns></returns>
        private static int P_PickListReport_GetTotal(DataTable dtReport)
        {
            int int_Total = 0;

            for (int i = 0; i < dtReport.Rows.Count; i++)
            {
                int_Total += Convert.ToInt32(dtReport.Rows[i]["Yote_QT"].ToString());
            }

            return int_Total;
        }

        #endregion

        #region"Report"

        #region"Actual Data Excel Export"

        public static bool G_F_Report_Excel_Export_Print_GetExcelData(string str_SP_NM, string str_date_S, string str_date_E, out DataSet out_ds)
        {
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    out_ds = null;
                    P_MessageBox_Connection();
                    return false;
                }
                SqlCommand sqlCmd = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ST_DT", ParameterDirection.Input, SqlDbType.VarChar, 10, str_date_S);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ED_DT", ParameterDirection.Input, SqlDbType.VarChar, 10, str_date_E);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 50, G_CommonDefine.G_str_Customer_SEC_CD);

                //僗僩傾僪幚峴
                if (str_SP_NM == "USP_EXL_Lot_Stock")
                {
                    sqlPara = new SqlParameter[4];
                    sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ST_DT", ParameterDirection.Input, SqlDbType.VarChar, 10, str_date_S);
                    sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ED_DT", ParameterDirection.Input, SqlDbType.VarChar, 10, str_date_E);
                    sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 10, G_CommonDefine.G_str_Customer_CD);
                    sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 50, G_CommonDefine.G_str_Customer_SEC_CD);

                }

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCmd, str_SP_NM, sqlPara, out out_ds);
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show("G_F_Report_Excel_Export_Print_GetExcelData Error:" + err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Report_Excel_Export_Print_GetExcelData Error" + err.Message, "G_F_Report_Excel_Export_Print_GetExcelData");
                out_ds = null;
                return false;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return true;
        }

        public static DataTable G_F_Report_ActualDeliveryList_GetData(string str_PC_NM)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 20, str_PC_NM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_Excel_ActualDeliveryList", sqlPara, out ds);
                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Report_ActualDeliveryList_GetData Error:" + err.Message, "G_F_Report_ActualDeliveryList_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }


        public static bool G_F_Report_Excel_Export_Print_GetExcelData4(string str_SP_NM, string str_date_S, string str_date_E,string str_Souk_CD, out DataSet out_ds)
        {
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    out_ds = null;
                    P_MessageBox_Connection();
                    return false;
                }
                SqlCommand sqlCmd = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[4];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ST_DT", ParameterDirection.Input, SqlDbType.VarChar, 10, str_date_S);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ED_DT", ParameterDirection.Input, SqlDbType.VarChar, 10, str_date_E);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 10, str_Souk_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 50, G_CommonDefine.G_str_Customer_SEC_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCmd, str_SP_NM, sqlPara, out out_ds);
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show("G_F_Report_Excel_Export_Print_GetExcelData Error:" + err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Report_Excel_Export_Print_GetExcelData Error" + err.Message, "G_F_Report_Excel_Export_Print_GetExcelData");
                out_ds = null;
                return false;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return true;
        }


        #endregion

        #region"Picking List Screen"

        #region "Select"
        /// <summary>
        /// Picklisg List Data
        /// </summary>
        /// <returns></returns>
        public static DataTable G_F_Report_PickingList_GetData(string str_PC_NM)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 20, str_PC_NM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Report_PickingList_DataSelect", sqlPara, out ds);
                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Report_PickingList_GetData Error:" + err.Message, "G_F_Report_PickingList_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        #endregion

        #region "Insert"

        public static bool G_F_Report_PickingList_MakeReprintReportSource(int int_Mode, string str_Pic_No, string str_PC_NM, int int_Res_Times, string str_Syk_DT)
        {
            string str_Message = string.Empty;
            string str_Caption = string.Empty;
            SqlConnection connect = null;

            try
            {
                //ログ書込み
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.ProcStart, "P_MakeReprintReportSource Start", "P_MakeReprintReportSource");

                //DB接続
                if (!G_CommonClassDB.G_DB_Connect(out connect))
                {
                    //エラーメッセージ表示
                    P_MessageBox_Connection();
                    return false;
                }

                SqlCommand sqlCmd = connect.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[6];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, int_Mode.ToString());
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Pic_No", ParameterDirection.Input, SqlDbType.VarChar, 20, str_Pic_No);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 25, str_PC_NM);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Res_Times", ParameterDirection.Input, SqlDbType.Int, 0, int_Res_Times.ToString());
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@P_Date", ParameterDirection.Input, SqlDbType.VarChar, 10, str_Syk_DT);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");
                SqlParameter[] sqloutpara;

                //ストアド実行
                G_CommonClassDB.G_DB_ExecStoredProc(connect, sqlCmd, "USP_PC_F_Report_PickingList_DataInsert", sqlPara, out sqloutpara);

                //返り値チェック
                if (sqloutpara[0].Value.ToString() != "0")
                {
                    str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_PickingInsertError);
                    str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Check);
                    //MessageBox.Show("ピッキングリスト出力対象レコード生成でエラーが発生しました。", "確認ー", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return false;
                }

                //ログ書込み
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.ProcEnd, "P_MakeReprintReportSource End", "P_MakeReprintReportSource");

                //正常値を返す
                return true;
            }
            catch (Exception err)
            {
                //ログ書込み
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "P_PrintPickingList Error" + err.Message, "P_PrintPickingList");

                //エラーメッセージ表示
                str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show("P_PrintPickingList Error" + err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);

                //異常値を返す
                return false;
            }
            finally
            {
                if (connect != null)
                {
                    //DB開放
                    if (!G_CommonClassDB.G_DB_Dispose(connect))
                    {
                        //エラーメッセージ表示
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static bool G_F_Report_PickingList_InsertForExcelExport(string str_StartDate, string str_EndDate)
        {
            SqlConnection sqlConnection = null;
            string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return false;
                }

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[5];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@StartDate", ParameterDirection.Input, SqlDbType.VarChar, 10, str_StartDate);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@EndDate", ParameterDirection.Input, SqlDbType.VarChar, 10, str_EndDate);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 50, G_CommonDefine.G_str_Customer_SEC_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 50, G_CommonDefine.G_PCNM);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@RET", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutpara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Report_PickingList_DataInsert_Export", sqlPara, out sqloutpara);

                if ((sqloutpara.Length > 0) && (sqloutpara[0].Value.ToString().Equals("0")))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception err)
            {

                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #endregion

        #region "Serial"

        #region"Delete"

        /// <summary>
        /// Delete Serial
        /// </summary>
        /// <param name="str_ID"></param>
        /// <returns></returns>
        public static int G_F_Report_Serial_DataDelete(string str_ID)
        {
            SqlConnection sqlConnection = null;
            int result = 99;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[2]; 
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ID", ParameterDirection.Input, SqlDbType.Int, 0, str_ID);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqlOutPara;
                if (G_CommonDefine.G_str_Customer_CD == "FDTH" || (G_CommonDefine.G_str_Customer_CD == "EIC"))
                {
                    G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Report_T_LOT_DataDelete", sqlPara, out sqlOutPara);
                }
                else
                    G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Report_T_Serial_DataDelete", sqlPara, out sqlOutPara);

                result = Convert.ToInt32(sqlOutPara[0].Value.ToString());
            }
            catch (Exception err)
            {
                if (G_CommonDefine.G_str_Customer_CD == "FDTH" || (G_CommonDefine.G_str_Customer_CD == "EIC"))
                    G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Report_LOT_DataDelete:" + err.Message, "G_F_Report_LOT_DataDelete");
                else G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Report_Serial_DataDelete:" + err.Message, "G_F_Report_Serial_DataDelete");

                MessageBox.Show(err.Message);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #endregion

        #region"Excel Operator"

        public static void DataTableToExcel(DataTable dt, Microsoft.Office.Interop.Excel.Range range)
        {
            int rowCount = dt.Rows.Count;
            int colCount = dt.Columns.Count;
            object[,] dataArray = new object[rowCount + 1, colCount];
            for (int k = 0; k < colCount; k++)
            {
                dataArray[0, k] = dt.Columns[k].ColumnName;
            }
            for (int i = 0; i < rowCount; i++)
            {
                for (int j = 0; j < colCount; j++)
                {
                    dataArray[i + 1, j] = dt.Rows[i][j];
                }
            }
            //excelSheet.get_Range("A1", excelSheet.Cells[rowCount, colCount]).Value2 = dataArray;
            range.Value2 = dataArray;
        }

        #endregion

        #region"Serial Stock List"

        public static DataTable G_F_Reprot_SerialStockList_GetData(string str_Shoh_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                if ((G_CommonDefine.G_str_Customer_CD == "FDTH") || (G_CommonDefine.G_str_Customer_CD == "EIC"))
                {
                    sqlPara = new SqlParameter[2];
                    sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);
                    sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_CD);
                    G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Report_LotStock", sqlPara, out ds);
                }
                else
                    G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Report_SerialStockList", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        public static DataTable G_F_Reprot_SerialStockList_Error_GetData(string str_Shoh_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Report_SerialStockList_Error", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }



        #endregion

        #region"All Lot Editing"
        public static int G_F_Reprot_All_lot_EditData(string str_ID, string lot_no, string QTY)
        {
            SqlConnection sqlConnection = null;
            int result = 99;
            SqlParameter[] sqlOutPara;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[5];
                    sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ID", ParameterDirection.Input, SqlDbType.Int, 0, str_ID);
                    sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@lot_no", ParameterDirection.Input, SqlDbType.VarChar, 0, lot_no);
                    sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@QTY", ParameterDirection.Input, SqlDbType.Int, 0, QTY);
                    sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_CD);
                    sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");
                    
                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Report_T_ALLLOT_DataEdit", sqlPara, out sqlOutPara);
               
                result = Convert.ToInt32(sqlOutPara[0].Value);
            }
            catch (Exception err)
            {
               
                    G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_Report_LOT_DataEdit:" + err.Message, "G_F_Report_LOT_DataDelete");
               
                MessageBox.Show(err.Message);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }
        #endregion
        #region"Lot Receiving"

        public static DataTable G_F_Reprot_LotReceiving_GetData(string STR_INVOICE_NO, string STR_PO_NO,string ST_DT , string ED_DT,string print)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[6];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_CD", ParameterDirection.Input, SqlDbType.VarChar, 50, STR_INVOICE_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PO", ParameterDirection.Input, SqlDbType.VarChar, 50, STR_PO_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ST_DT", ParameterDirection.Input, SqlDbType.VarChar, 10, ST_DT);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ED_DT", ParameterDirection.Input, SqlDbType.VarChar, 10, ED_DT);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Print", ParameterDirection.Input, SqlDbType.VarChar, 10, print);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 10, G_CommonDefine.G_str_Customer_CD);
                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Report_LotReceiving", sqlPara, out ds);
                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        public static DataTable G_F_Reprot_LotReceiving_Error_GetData(string str_Shoh_CD)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Shoh_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Report_SerialStockList_Error", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }



        #endregion


        #region"Packing Detail Entry for SH"

        #region"Select"

        public static int G_F_Syk_EntrySykPackDetail_SH_SUB_DataDelete()
        {
            int result = -1;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[2];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykPackDetail_SH_SUB_DataDelete", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());
            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        public static int G_F_Syk_EntrySykPackDetail_SH_SUB_DataInsert(string str_PicED_DT, string str_unso_CD, string str_SECTION_CODE)
        {
            int result = -1;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[6];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PicED_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PicED_DT);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_unso_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_CD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykPackDetail_SH_SUB_DataInsert", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }


        public static int G_F_Syk_EntrySykPackDetail_HK_SUB_DataInsert(string str_PicED_DT, string str_InvoiceNo, string str_SECTION_CODE)
        {

            int result = -1;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[6];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PicED_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PicED_DT);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_InvoiceNo);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_CD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykPackDetail_HK_SUB_DataInsert_TWO", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        public static int G_F_Syk_EntrySykPackDetail_SH_SUB_DataInsert_OLD(string str_PicED_DT, string str_unso_CD, string str_SECTION_CODE)
        {
            int result = -1;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[5];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PicED_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PicED_DT);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@unso_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_unso_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykPackDetail_SH_SUB_DataInsert", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        public static DataSet G_F_Syk_EntrySykPackDetail_SH_SUB_DataSelect(string Cust_No)
        {
            SqlConnection sqlConnection = null;
            DataSet ds;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return null;
                }
                
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[2];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_No", ParameterDirection.Input, SqlDbType.VarChar, 0, Cust_No);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykPackDetail_SH_SUB_DataSelect", sqlPara, out ds);

                //if ((ds != null) && (ds.Tables.Count > 0))
                //{
                //    dt = ds.Tables[0];
                //}

            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }
            finally
            {
                if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                {
                    P_MessageBox_Disconnection();
                }
            }
            return ds;
        }


        public static DataSet G_F_Syk_EntrySykPackDetail_HK_SUB_DataSelect(string Cust_No,string str_SECTION_CODE)
        {
            SqlConnection sqlConnection = null;
            DataSet ds;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return null;
                }

                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[3];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_No", ParameterDirection.Input, SqlDbType.VarChar, 0, Cust_No);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SECTION_CODE", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SECTION_CODE);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykPackDetail_HK_SUB_DataSelect_TWO", sqlPara, out ds);

                //if ((ds != null) && (ds.Tables.Count > 0))
                //{
                //    dt = ds.Tables[0];
                //}

            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }
            finally
            {
                if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                {
                    P_MessageBox_Disconnection();
                }
            }
            return ds;
        }

        public static DataTable G_F_Syk_EntrySykPackDetail_SH_SUB_DataSelect_OLD()
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykPackDetail_SH_SUB_DataSelect_OLD", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                {
                    P_MessageBox_Disconnection();
                }
            }
            return dt;
        }

        public static DataTable G_F_Syk_EntrySykPackDetail_SH_SUB_DataSelect_Report()
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykPackDetail_SH_PackingReport_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                {
                    P_MessageBox_Disconnection();
                }
            }
            return dt;
        }


        public static DataTable G_F_Syk_EntrySykPackDetail_SH_SUB_SURE()
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykPackDetail_SH_SURE", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                {
                    P_MessageBox_Disconnection();
                }
            }
            return dt;
        }

        public static string G_F_Syk_EntrySykPackDetail_SH_OLD_GetPrinterName()
        {
            string strPrinterName = string.Empty;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return strPrinterName;
                }

                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 50,G_CommonDefine.G_PCNM);
                //G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, out ds, "USP_PC_F_Syk_EntrySykPackDetail_SH_SUB_GetPrinterName");
                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykPackDetail_SH_SUB_GetPrinterName", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count > 0))
                {
                    strPrinterName = ds.Tables[0].Rows[0][0].ToString();
                }

                return strPrinterName;
            }
            catch (Exception err)
            {

                MessageBox.Show(err.Message);
                return strPrinterName;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }


        public static void G_F_Syk_EntrySykPackDetail_SH_OLD_SETPrinterName(string str_Printer_Name)
        {
           
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    
                }

                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[2];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 50, G_CommonDefine.G_PCNM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Printer_NM", ParameterDirection.Input, SqlDbType.VarChar, 50, str_Printer_Name);
              
                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykPackDetail_SH_SUB_SETPrinterName", sqlPara, out ds);

            }
            catch (Exception err)
            {

                MessageBox.Show(err.Message);
              
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #region "Update"

        public static int G_F_Syk_EntrySykPackDetail_SH_SUB_DataUpdate(string str_Mode, string str_Cust_NO, string str_Case_NO, string str_Select_FG,string str_TL_ID)
        {
            int result = -1;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[7];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Case_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Case_NO);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Select_FG", ParameterDirection.Input, SqlDbType.Int, 0, str_Select_FG);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@TL_ID", ParameterDirection.Input, SqlDbType.Int, 0, str_TL_ID);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykPackDetail_SH_SUB_DataUpdate", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        public static int G_F_Syk_EntrySykPackDetail_SH_SUB_DataUpdate_OLD(string str_Mode, string str_Cust_NO, string str_Case_NO, string str_Select_FG)
        {
            int result = -1;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[6];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Case_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Case_NO);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Select_FG", ParameterDirection.Input, SqlDbType.Int, 0, str_Select_FG);

                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykPackDetail_SH_SUB_DataUpdate_OLD", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }


        #endregion

        #region "Packing Excel Report"

        public static void G_F_Syk_EntrySykPackDetail_SH_SUB_PackingReport()
        {
            string str_Message = string.Empty;
            string str_Caption = string.Empty;

            try
            {
                ExcelAccess xlReport = new ExcelAccess();
                string strPath = Application.StartupPath + @"\Report";
                string strExcelTemplateFile = System.IO.Path.GetFullPath(strPath + @"\PackingListforSH.xlt");
                string str_InitialDir = @G_CommonClassSystem.G_System_GetDeskTopPath().ToString();

                if (!System.IO.File.Exists(strExcelTemplateFile))
                {
                    str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Excel_Template_NoExists);
                    str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                    MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    xlReport.Close();
                    return;
                }

                DataTable dt = G_F_Syk_EntrySykPackDetail_SH_SUB_DataSelect_Report();
                if ((dt == null) || (dt.Rows.Count == 0))
                {
                    str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_DataNotExist);
                    str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Information);
                    MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    xlReport.Close();
                    return;
                }

                xlReport.Open(strExcelTemplateFile);

                int pageRowCount = 32;//明细行数
                int pageTotal = 50;//每页总行数

                int rowIndex = 0;

                int pageChild;
                int pageParent;
                pageParent = P_PackingReport_ComputePage(ref dt, pageRowCount);

                Microsoft.Office.Interop.Excel.Range range;
                Microsoft.Office.Interop.Excel.Range subRange;
                object oMissing = System.Reflection.Missing.Value;
                string str_Header = "          签    收    单              ";
                for (pageChild = 1; pageChild <= pageParent; pageChild++)
                {
                    DataRow[] Rows = dt.Select("PageChild=" + pageChild + "");
                    //列表头
                    range = xlReport.GetRange(rowIndex + 1, "A", rowIndex + 1, "F");
                    range.Merge(oMissing);
                    range.RowHeight = 30.75;
                    range.Font.Size = 20;
                    xlReport.SetCellText(range, str_Header);

                    //Order Custoemr Information

                    xlReport.SetCellText(rowIndex + 2, "A", "客户名称：");
                    xlReport.SetCellText(rowIndex + 2, "B", Rows[0]["Toku_NM_01"].ToString());

                    xlReport.SetCellText(rowIndex + 3, "A", "日    期：");
                    xlReport.SetCellText(rowIndex + 3, "B", Rows[0]["Siji_DT"].ToString());

                    xlReport.SetCellText(rowIndex + 4, "A", "货物数量：");
                    xlReport.SetCellText(rowIndex + 4, "B", "");

                    xlReport.SetCellText(rowIndex + 4, "A", "明细如下：");
                    xlReport.SetCellText(rowIndex + 4, "B", "");

                    xlReport.SetCellText(rowIndex + 2, "D", "客户地址：");
                    range = xlReport.GetRange(rowIndex + 2, "E", rowIndex + 2, "F");
                    range.Merge(oMissing);
                    string Toku_AD = Rows[0]["Toku_AD_01"].ToString() + Rows[0]["Toku_AD_02"].ToString() + Rows[0]["Toku_AD_03"].ToString();
                    xlReport.SetCellText(range, Toku_AD);

                    xlReport.SetCellText(rowIndex + 3, "D", "电    话：");
                    range = xlReport.GetRange(rowIndex + 3, "E", rowIndex + 3, "F");
                    range.Merge(oMissing);
                    xlReport.SetCellText(range, Rows[0]["Toku_Tel_NO"].ToString());

                    xlReport.SetCellText(rowIndex + 4, "D", "联 系 人：");
                    range = xlReport.GetRange(rowIndex + 4, "E", rowIndex + 4, "F");
                    range.Merge(oMissing);
                    xlReport.SetCellText(range, Rows[0]["Toku_NM_02"].ToString());

                    //明细    
                    int total = 0;
                    for (int i = 0; i < Rows.Length; i++)
                    {
                        int startIndex = rowIndex + 6 + i;
                        DataRow Row = Rows[i];
                        xlReport.SetCellText(startIndex, "A", Row["Case_NO"].ToString());
                        //range = xlReport.GetRange(startIndex, "B", startIndex, "E");
                        //range.Merge(oMissing);
                        xlReport.SetCellText(startIndex, "B", Row["Shoh_CD"].ToString());
                        xlReport.SetCellText(startIndex, "F", Row["Yote_QT"].ToString());
                        total += Convert.ToInt32(Row["Yote_QT"].ToString());
                    }

                    //object[,] dataArray = new object[Rows.Length, 3];

                    //for (int i = 0; i < Rows.Length; i++)
                    //{
                    //    DataRow Row = Rows[i];
                    //    dataArray[i, 0] = Row["Case_NO"].ToString();
                    //    dataArray[i, 1] = Row["Shoh_CD"].ToString();
                    //    dataArray[i, 2] = Row["Yote_QT"].ToString();


                    //}

                    //range = xlReport.GetRange(rowIndex + 6, "A", rowIndex + 6 + Rows.Length, "F");
                    //range.Value2 = dataArray;
                    xlReport.SetCellText(rowIndex + 40, "A", "共  计：");
                    xlReport.SetCellText(rowIndex + 40, "F", total.ToString());
                    xlReport.SetCellText(rowIndex + 41, "A", "订单号：");
                    //页尾
                    if (pageChild != 1)
                    {
                        range = xlReport.GetRange(42, "A", 50, "F");
                        range.Copy(oMissing);
                        subRange = xlReport.GetRange(rowIndex + 42, "A");
                        subRange.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, oMissing, oMissing);
                        range = xlReport.GetRange(rowIndex + 42, "A", rowIndex + 45, "F");
                        range.RowHeight = 20;
                    }
                    xlReport.InsertHPageBreaks(rowIndex + pageTotal);
                    rowIndex += pageTotal;
                }

                //xlReport.PrintPreview();
                //保存Excel
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "(*.xls)|*.xls|(*.*)|*.*";
                saveFileDialog.FileName = "Packing List" + DateTime.Now.ToString("yyyyMMddHHmmss");
                saveFileDialog.InitialDirectory = str_InitialDir;
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    xlReport.SaveAs(saveFileDialog.FileName, true);
                }

                //xlReport.Application.ActivePrinter = @"\\PC01\PTE01 在 Ne04:";
                //xlReport.PrintPreview();
                xlReport.Close();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private static int P_PackingReport_ComputePage(ref DataTable dt, int pageRowCount)
        {
            string str_Cust_No_Old = string.Empty;
            string str_Cust_No_New = string.Empty;
            int pageChild = 0;
            int pageParent = 0;
            int RowIndex = 0;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow Row = dt.Rows[i];
                str_Cust_No_New = Row["Cust_NO"].ToString().Trim().ToLower();

                if (str_Cust_No_New != str_Cust_No_Old)
                {
                    pageParent++;
                    pageChild++;
                    RowIndex = 1;
                    str_Cust_No_Old = str_Cust_No_New;
                    Row["PageChild"] = pageChild.ToString();

                }
                else
                {
                    if (RowIndex > pageRowCount)
                    {
                        RowIndex = 1;
                        pageParent++;
                        pageChild++;
                        Row["PageChild"] = pageChild.ToString();
                    }
                    else
                    {
                        if (pageChild == 0)//防止 Cust_NO = "" 
                        {
                            pageParent++;
                            pageChild++;
                        }
                        RowIndex++;
                        Row["PageChild"] = pageChild.ToString();
                    }
                }
            }
            return pageParent;
        }

        #endregion

        #endregion

        #region "Stock Taking"


        public static int G_F_Report_TanaOroshiList_HHT_DataUpdate(string strMode, string str_Tori_CD, string str_Nins_CD, string[] strLoca_CD)
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            SqlTransaction tran = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                tran = sqlConnection.BeginTransaction();

                SqlBulkCopy sqlCopy = new SqlBulkCopy(sqlConnection, SqlBulkCopyOptions.Default, tran);
                sqlCopy.BatchSize = 100;
                //sqlCopy.ColumnMappings.Add("PC_NM", "PC_NM");
                //sqlCopy.ColumnMappings.Add("FB_NO", "FB_NO");
                //sqlCopy.ColumnMappings.Add("FBPOS_NO", "FBPOS_NO");
                //sqlCopy.ColumnMappings.Add("Shoh_CD", "Shoh_CD");
                //sqlCopy.ColumnMappings.Add("Shoh_NM", "Shoh_NM");
                //sqlCopy.ColumnMappings.Add("Yote_QT", "Yote_QT");
                //sqlCopy.ColumnMappings.Add("M_LoStock_ID", "M_LoStock_ID");
                //sqlCopy.ColumnMappings.Add("Pick_QT", "Pick_QT");

                DataTable dt = new DataTable();

                dt.Columns.Add("Tori_CD", typeof(string));
                dt.Columns.Add("Nins_CD", typeof(string));
                dt.Columns.Add("Loca_CD", typeof(string));
                dt.Columns.Add("PC_NM", typeof(string));
                dt.Columns.Add("UPD_DT", typeof(string));

                foreach (string s in strLoca_CD)
                {
                    DataRow Row = dt.NewRow();
                    Row["Tori_CD"] = str_Tori_CD;
                    Row["Nins_CD"] = str_Nins_CD;
                    Row["Loca_CD"] = s;
                    Row["PC_NM"] = G_CommonDefine.G_PCNM;
                    Row["UPD_DT"] = DateTime.Now.ToString();

                    dt.Rows.Add(Row);
                }

                dt.AcceptChanges();

                sqlCopy.ColumnMappings.Add("Tori_CD", "Tori_CD");
                sqlCopy.ColumnMappings.Add("Nins_CD", "Nins_CD");
                sqlCopy.ColumnMappings.Add("Loca_CD", "Loca_CD");
                sqlCopy.ColumnMappings.Add("PC_NM", "PC_NM");
                sqlCopy.ColumnMappings.Add("UPD_DT", "UPD_DT");

                sqlCopy.DestinationTableName = "T_WK_TanaOroshi_HHT";

                sqlCopy.WriteToServer(dt);

                tran.Commit();

                result = 0;
                return result;
            }
            catch (Exception err)
            {
                if (tran != null)
                {
                    tran.Rollback();
                }
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #endregion

        #region"HOEI Actual Receiving Records Get"

        public static DataSet G_F_EDI_NYK_Result_HOEI_GetData(string str_Cust_NO, string str_Jyht_NO, string str_Jisk_DT)
        {
            DataTable dt = null;
            DataSet ds = null;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return ds;
                }

                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[4];
                //sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@DO_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_DO_NO);
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyht_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jyht_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jisk_DT", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Jisk_DT);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_CD);
                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_EDI_Result_NykData_HOEI_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_EDI_NYK_Result_HOEI_GetData Error", "G_F_EDI_NYK_Result_HOEI_GetData");
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return ds;
        }


        #endregion

        #region"Receiving"

        #region"HOEI Receiveing Inspection by PC"

        #region "Seach Data"

        public static DataTable G_F_Nyk_Inspection_HK_GetData(string str_Cust_NO, string str_Siji_DT, string str_Search_Mode, string str_Search_CD)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[6];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Cust_NO);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Siji_DT", ParameterDirection.Input, SqlDbType.DateTime, 0, str_Siji_DT);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                //Modify by Michael Date:2009-06-08
                switch (G_CommonDefine.G_str_Customer_CD)
                {
                    case "HOEI":
                        G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Nyk_Inspection_HK_DataSelect", sqlPara, out ds);
                        break;
                    default:
                        G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Nyk_Inspection_HK_DataSelect_FEA", sqlPara, out ds);
                        break;
                }
   

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception err)
            {

                MessageBox.Show(err.Message);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }


        public static DataTable G_F_Nyk_Inspection_HK_Sub_GetData()
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[1];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Nyk_Inspection_HK_SUB_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

                return dt;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

        }

        public static string G_F_Nyk_Inspection_HK_GetLotNO()
        {
            string Lot_CD = string.Empty;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return Lot_CD;
                }
               
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[3];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 10, G_CommonDefine.G_str_Customer_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@No_KB", ParameterDirection.Input, SqlDbType.VarChar, 50, "Lot_NO");
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.VarChar, 50, "0");

                SqlParameter[] sqlOutPara = null;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_COM_NO_DataSelect", sqlPara, out sqlOutPara);

                if ((sqlOutPara != null) && (sqlOutPara.Length > 0))
                {
                    Lot_CD = sqlOutPara[0].Value.ToString();
                }
                return Lot_CD;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return Lot_CD;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #region "Update"

        public static int G_F_Nyk_Inspection_HK_SUB_DataUpdate(G_CommonClassDBEntry.Nyk_Inspection_HK nyk)
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[28];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, nyk.str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ID", ParameterDirection.Input, SqlDbType.Int, 0, nyk.str_ID);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, nyk.str_Tori_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nins_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, nyk.str_Nins_CD);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, nyk.str_FB_NO);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FBPOS_NO", ParameterDirection.Input, SqlDbType.Int, 0, nyk.str_FBPOS_NO);

                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyht_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, nyk.str_Jyht_NO);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@LINE_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, nyk.str_LINE_NO);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, nyk.str_Shoh_CD);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Shoh_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, nyk.str_Shoh_NM);
                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Yote_QT", ParameterDirection.Input, SqlDbType.Int, 0, nyk.str_Yote_QT);

                sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jyot_KB", ParameterDirection.Input, SqlDbType.VarChar, 0, nyk.str_Jyot_KB);
                sqlPara[12] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tani_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, nyk.str_Tani_NM);
                sqlPara[13] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Inspection_QTY", ParameterDirection.Input, SqlDbType.Int, 0, nyk.str_Inspection_QTY);
                sqlPara[14] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Prio_NO", ParameterDirection.Input, SqlDbType.Int, 0, nyk.str_Prio_NO);
                sqlPara[15] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Lot_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, nyk.str_Lot_CD);

                sqlPara[16] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Iri_QT", ParameterDirection.Input, SqlDbType.Int, 0, nyk.str_Iri_QT);
                sqlPara[17] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Jisk_QT", ParameterDirection.Input, SqlDbType.Int, 0, nyk.str_Jisk_QT);
                sqlPara[18] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Label_QT", ParameterDirection.Input, SqlDbType.Int, 0, nyk.str_Label_QT);
                sqlPara[19] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, nyk.str_PC_NM);

                sqlPara[20] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Cust_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, nyk.str_Cust_NO);
                sqlPara[21] = G_CommonClassDB.G_DB_SetSQLDBParameter("@OSPos_No", ParameterDirection.Input, SqlDbType.Int, 0, nyk.str_OSPos_No);
                sqlPara[22] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Nyuk_DT", ParameterDirection.Input, SqlDbType.SmallDateTime, 0, nyk.str_Nyuk_DT);
                sqlPara[23] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Para_ID", ParameterDirection.Input, SqlDbType.Int, 0, nyk.str_Para_ID);
                sqlPara[24] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Line_No_Internal", ParameterDirection.Input, SqlDbType.Int, 0, nyk.str_Line_No_Internal);

                sqlPara[25] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, nyk.str_Souk_CD);
                sqlPara[26] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Souk_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, nyk.str_Souk_NM);

                sqlPara[27] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara = null;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Nyk_Inspection_HK_SUB_DataUpdate", sqlPara, out sqloutPara);


                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                return result;

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static int G_F_Nyk_Inspection_HK_DataUpdate_POBAL()
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            //SqlTransaction tran = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Disconnection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[6];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_GP);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_WorkCD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Nyk_Inspection_HK_DataUpdate_01", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                return result;

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Connection();
                    }
                }
            }
        }

        public static int G_F_Nyk_Inspection_HK_DataUpdate_TL()
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            //SqlTransaction tran = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Disconnection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[6];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_GP);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_WorkCD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Nyk_Inspection_HK_DataUpdate_TL", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                return result;

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Connection();
                    }
                }
            }
        }

        public static int G_F_Nyk_Inspection_HK_CheckPrinter(string str_Printer_NM, ref string str_oldPrint_NM)
        {
            int result = -99;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[4];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 50, G_CommonDefine.G_PCNM);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Printer_NM", ParameterDirection.Input, SqlDbType.VarChar, 50, str_Printer_NM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@oldPrint_NM", ParameterDirection.Output, SqlDbType.VarChar, 50, "");
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Nyk_Inspection_HK_CheckPrinter", sqlPara, out sqloutPara);

                str_oldPrint_NM = sqloutPara[0].Value.ToString();

                result = Convert.ToInt32(sqloutPara[1].Value.ToString());

                return result;
            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static DataTable G_F_Nyk_Inspection_HK_GetPrinterData()
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;


                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, out ds, "USP_PC_F_Nyk_Inspection_HK_GetPrinter");

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static void G_F_Nyk_Inspection_HK_Sub_DataDelete(string str_Mode)
        {
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return;
                }
                SqlParameter[] sqlPara = new SqlParameter[2];
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Nyk_Inspection_HK_Sub_DataDelete", sqlPara, out sqloutPara);

            }
            catch (Exception err)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }


        /// <summary>
        /// Print Carton Label
        /// </summary>
        /// <param name="str_PrinterName"></param>
        /// <returns></returns>
        public static void G_F_Nyk_Inspection_HK_PrintCartonLabel(string str_PrinterName)
        {
            try
            {
                DataSet ds = G_F_Nyk_Inspection_HK_GetCartonLabelData();
                if ((ds == null) || (ds.Tables.Count == 0))
                {
                    return;
                }
                // レポートを生成してビューワコントロールに表示します。
                Assembly asm = Assembly.GetExecutingAssembly();
                Type t;
                Object obj;

                ReportDocument rpt;

                //                        t = asm.GetType(asm.GetName().Name + "." + ds.Tables[0].Rows[i]["Print_NM"].ToString());
                t = asm.GetType("FBWMS.Report.R_HOEI_Carton");
                obj = t.InvokeMember(null, BindingFlags.CreateInstance, null, null, null);
                rpt = (ReportDocument)(obj);
                ds_Label.DataDataTable dt_Report = new ds_Label.DataDataTable();
                if (P_F_Nyk_Inspection_HK_SetCartonLabel(ds,ref dt_Report))
                {
                    rpt.SetDataSource((DataTable)dt_Report);

                    //cy.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)int_Paper;
                    BlobFieldObject imageObject =
                        (BlobFieldObject)rpt.ReportDefinition.ReportObjects["BarCode1"] as BlobFieldObject;
                    imageObject.Width = 91 * 15; //报表中的长宽单位是缇，1像素=15缇
                    imageObject.Height = 91 * 15;

                }

                rpt.PrintToPrinter(1, true, 0, 0);

            }
            catch (Exception err)
            {

                MessageBox.Show(err.Message);
            }
        }

        public static DataSet G_F_Nyk_Inspection_HK_GetCartonLabelData()
        {
            DataSet ds = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return ds;
                }
               
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 50, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Nyk_Inspection_HK_Carton_DataSelect", sqlPara, out ds);

  
                return ds;
            }
            catch (Exception err)
            {


                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return ds;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        private static bool P_F_Nyk_Inspection_HK_SetCartonLabel(DataSet ds_R_HOEI_Carton, ref ds_Label.DataDataTable dt_Report)
        {
            DotNetBarcode bc = new DotNetBarcode(DotNetBarcode.Types.QRCode);
            string str_Binary = "";
            DateTime dt_Date = DateTime.Now;
            string str_Date = "";

            int int_Paper = -1;
            dt_Report = new ds_Label.DataDataTable();
            for (int j = 0; j < ds_R_HOEI_Carton.Tables[0].Rows.Count; j++)
            {
                //string str_Data = ds_R_HOEI_Carton.Tables[0].Rows[j]["Troi_CD"].ToString() + "<#$>" +
                //    ds_R_HOEI_Carton.Tables[0].Rows[j]["Shoh_CD"].ToString() + "<#$>" +
                //    ds_R_HOEI_Carton.Tables[0].Rows[j]["Condition"].ToString() + "<#$>" +
                //    ds_R_HOEI_Carton.Tables[0].Rows[j]["REF"].ToString() + "<#$>" +
                //    ds_R_HOEI_Carton.Tables[0].Rows[j]["Date"].ToString() + "<#$>" +
                //    ds_R_HOEI_Carton.Tables[0].Rows[j]["Work_CD"].ToString() + "<#$>" +
                //    ds_R_HOEI_Carton.Tables[0].Rows[j]["Qty"].ToString() + "<#$>" +
                //    ds_R_HOEI_Carton.Tables[0].Rows[j]["Label"].ToString() + "<#$>" +
                //    ds_R_HOEI_Carton.Tables[0].Rows[j]["Lot_No"].ToString() + "<#$>" +
                //    ds_R_HOEI_Carton.Tables[0].Rows[j]["FB_NO"].ToString() + "<#$>" +
                //    ds_R_HOEI_Carton.Tables[0].Rows[j]["FBPOS_NO"].ToString() + "<#$>" +
                //    ds_R_HOEI_Carton.Tables[0].Rows[j]["int_StartSeq"].ToString() + "<#$>" +
                //    ds_R_HOEI_Carton.Tables[0].Rows[j]["Location"].ToString() + "<#$>" +
                //    ds_R_HOEI_Carton.Tables[0].Rows[j]["MaxSeq"].ToString() + "<#$>" +
                //    ds_R_HOEI_Carton.Tables[0].Rows[j]["StrCondition"].ToString() + "<#$>";

                if (DateTime.TryParse(ds_R_HOEI_Carton.Tables[0].Rows[j]["NYUK_DT"].ToString(), out dt_Date))
                {
                    str_Date = dt_Date.Year.ToString("D4") + dt_Date.Month.ToString("D2") + dt_Date.Day.ToString("D2");
                }

                ds_Label.DataRow dr_lb = dt_Report.NewDataRow();
                dr_lb.Tori_CD = ds_R_HOEI_Carton.Tables[0].Rows[j]["Tori_CD"].ToString();
                dr_lb.Shoh_CD = ds_R_HOEI_Carton.Tables[0].Rows[j]["Shoh_CD"].ToString() + "\r\n" +
                    ds_R_HOEI_Carton.Tables[0].Rows[j]["Shoh_NM"].ToString();
                dr_lb.Souk_NM = ds_R_HOEI_Carton.Tables[0].Rows[j]["SOUK_CD"].ToString();

                dr_lb.Jyot_KB = ds_R_HOEI_Carton.Tables[0].Rows[j]["JYOT_NM"].ToString();
                dr_lb.Ref = ds_R_HOEI_Carton.Tables[0].Rows[j]["Lot_CD"].ToString();
                dr_lb.NOUK_DT = ds_R_HOEI_Carton.Tables[0].Rows[j]["NYUK_DT"].ToString();
                dr_lb.Work_CD = ds_R_HOEI_Carton.Tables[0].Rows[j]["WORK_CD"].ToString();

                dr_lb.Lot_No = ds_R_HOEI_Carton.Tables[0].Rows[j]["SUPPLIER_NM"].ToString();
                dr_lb.Qty = ds_R_HOEI_Carton.Tables[0].Rows[j]["ALL_QT"].ToString();
                dr_lb.CaseNo = "Location" + ds_R_HOEI_Carton.Tables[0].Rows[j]["B_Loca_CD"].ToString();
                //if (Info.Length > 15)
                //{
                //    dr_lb.IssuingDate = "重";
                //}

                str_Binary = "N" + SetLenth(ds_R_HOEI_Carton.Tables[0].Rows[j]["FB_NO"].ToString(), 20) +
                    SetLenth(ds_R_HOEI_Carton.Tables[0].Rows[j]["FBPOS_NO"].ToString(), 5) +
                    SetLenth(ds_R_HOEI_Carton.Tables[0].Rows[j]["SEQ_NO"].ToString(), 5) +
                    SetLenth(ds_R_HOEI_Carton.Tables[0].Rows[j]["Tori_CD"].ToString(), 15) +
                    SetLenth(ds_R_HOEI_Carton.Tables[0].Rows[j]["Shoh_CD"].ToString(), 80) +
                    SetLenth(ds_R_HOEI_Carton.Tables[0].Rows[j]["Lot_CD"].ToString(), 50) +
                    SetLenth("10", 2) +
                    SetLenth(ds_R_HOEI_Carton.Tables[0].Rows[j]["ALL_QT"].ToString(), 5) +
                    SetLenth(str_Date, 8);
                bc.Save(str_Binary, Application.StartupPath + @"\Temp.bmp", 200, 200);
                dr_lb.BarCode = File.ReadAllBytes(Application.StartupPath + @"\Temp.bmp");
                dr_lb.Invoice = ds_R_HOEI_Carton.Tables[0].Rows[j]["FB_NO"].ToString() + @"/" +
                    ds_R_HOEI_Carton.Tables[0].Rows[j]["FBPOS_NO"].ToString() + @"/" +
                    ds_R_HOEI_Carton.Tables[0].Rows[j]["SEQ_NO"].ToString();

                dr_lb.Page = ds_R_HOEI_Carton.Tables[0].Rows[j]["PAGE_SHOW"].ToString();
                //dt_Report.AcceptChanges();
                dt_Report.Rows.Add(dr_lb);
                //string str_Data = ds_R_HOEI_Carton.Tables[0].Rows[j]["Print_Content"].ToString();
                //string[] lstr_Values = str_Data.Split(new string[] { "<#&>" }, StringSplitOptions.RemoveEmptyEntries);
                //dt_Report.Rows.Clear();
                //foreach (string str_SubValue in lstr_Values)
                //{
                //    if (!str_SubValue.Contains("<#$>"))
                //    {
                //        continue;
                //    }

                //    G_Print_HOEI_Carton(str_SubValue.Substring(str_SubValue.IndexOf("<#$>") + 4));

                //}
                int_Paper = int_Paper + 1;
            }
            return true;
        }

        public static string SetLenth(string s, int len)
        {
            return s.Length > len ? s.Remove(len) : s.PadRight(len, ' ');
        }

        public static DataTable G_F_Nyk_Inspection_HK_GetDefaultPrinterData()
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Nyk_Inspection_HK_GetDefaultPrinter", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #region"A4 Label"

        public static void G_F_Nyk_Inspection_HK_PrinterA4Label(DataTable dtReport)
        {
            string str_Message = string.Empty;
            string str_Caption = string.Empty;
            
            try
            {
                 ExcelAccess xlReport = new ExcelAccess();

                string strPath = Application.StartupPath + @"\Report";
                string strExcelTemplateFile = System.IO.Path.GetFullPath(strPath + @"\Receiving_Inspection_by_PC_A4_Label.xlt");

                if (!System.IO.File.Exists(strExcelTemplateFile))
                {
                    str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Excel_Template_NoExists);
                    str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                    MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //DataSet ds = G_F_Nyk_Inspection_HK_GetCartonLabelData();
                //DataTable dtReport = null;
                //if ((ds != null) && (ds.Tables.Count > 0))
                //{
                //    dtReport = ds.Tables[0];
                //}

                //if ((dtReport == null) || (dtReport.Rows.Count == 0))
                //{
                //    return;
                //}

                //open excel
                xlReport.Open(strExcelTemplateFile);
                xlReport.IsVisibledExcel = true;

            
                Microsoft.Office.Interop.Excel.Range range;
                Microsoft.Office.Interop.Excel.Range subRange;
                Object oMissing = System.Reflection.Missing.Value;
                DotNetBarcode bc = new DotNetBarcode(DotNetBarcode.Types.QRCode);
                string str_Binary = "";
                string str_ImageFile = "";
                string str_Date = "";
                DateTime dt_Date = DateTime.Now;

                int pageChild = 0; //当前页 Current Page
                int pageParent = 1;//总页数 Total Page
                int RowIndex = 1; //索引行
                int PageTotalRowCount = 59;// 每页打印48行,第二页从49行开始
                int PagePrintRowCount = 11;//明细每页打印9行数据 Excel 明细行为 4*12 行
                int RowCount = 5;//一数据据在EXCEL 中点5行

                //计算页数
                pageParent = dtReport.Rows.Count / PagePrintRowCount;

                if ((dtReport.Rows.Count % PagePrintRowCount) != 0)
                {
                    pageParent += 1;
                }
                int i= 0;

                for (pageChild = 0; pageChild < pageParent; pageChild++)
                {
                    //到下一页
                    RowIndex = pageChild * PageTotalRowCount;
                    if (pageChild != 0)
                    {
                        //拷贝表头
                        range = xlReport.GetRange(2, "A", 4, "I");
                        range.Copy(oMissing);
                        subRange = xlReport.GetRange(RowIndex + 2, "A", RowIndex + 4, "I");
                        subRange.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll,Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, oMissing, oMissing);
                    }
                    //第五行为空行
                    //第六行开始写数据
                    //
                    //每页写一次数据
                    string[,] dataArrayPage = new string[55, 6];
                    int ArrarIndex = 0;
                    for (int j = 0; (j < PagePrintRowCount) && (i < dtReport.Rows.Count); j++)
                    {
                        DataRow Row = dtReport.Rows[i];

                        int Index = RowIndex + j * 5;

                        
                        if (i != 0)
                        {
                            subRange = xlReport.GetRange(6, "B", 6, "C");
                            subRange.Copy(oMissing);
                            range = xlReport.GetRange(Index + 6, "B", Index + 8, "C");
                            range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteFormats, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationMultiply, oMissing, oMissing);

                            range = xlReport.GetRange(Index + 6, "F", Index + 7, "F");
                            range.Merge(oMissing);
                            range.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignTop;
                            range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
                            range.WrapText = true;
                        }

                        //Product Code
                        dataArrayPage[ArrarIndex + 1, 0] = Row["Shoh_CD"].ToString();
                        //dataArray[ArrarIndex + 2, 0] = string.Empty;
                        //dataArray[ArrarIndex + 3, 0] = string.Empty;
                        //Product Name
                        dataArrayPage[ArrarIndex + 1, 1] = Row["Shoh_NM"].ToString();
                        //dataArray[ArrarIndex + 2, 1] = string.Empty;
                        //dataArray[ArrarIndex + 3, 1] = string.Empty;
                        //Lot_NO
                        dataArrayPage[ArrarIndex + 1, 2] = Row["Lot_CD"].ToString();//Lot_NO
                        dataArrayPage[ArrarIndex + 2, 2] = Row["Nyuk_DT"].ToString();//Receiving Date
                        dataArrayPage[ArrarIndex + 3, 2] = Row["FB_NO"].ToString() + "/" + Row["FBPOS_NO"].ToString() + "/" + Row["SEQ_NO"].ToString();//FB_NO
                        //Warehouse
                        dataArrayPage[ArrarIndex + 1, 3] = Row["SOUK_CD"].ToString();//Warehouse
                        dataArrayPage[ArrarIndex + 2, 3] = Row["Jyot_NM"].ToString();//Status
                        dataArrayPage[ArrarIndex + 3, 3] = Row["WORK_CD"].ToString();//Opeartor 
                        //Vender Code
                        dataArrayPage[ArrarIndex + 1, 4] = Row["SUPPLIER_NM"].ToString();
                        //dataArrayPage[ArrarIndex + 2, 4] = string.Empty;
                        dataArrayPage[ArrarIndex + 3, 4] = Row["Reg_DT"].ToString();//Reg_DT

                        dataArrayPage[ArrarIndex + 1, 5] = Row["All_QT"].ToString();
                        //dataArray[ArrarIndex + 2, 5] = string.Empty;
                        dataArrayPage[ArrarIndex + 3, 5] = Row["Page_Show"].ToString();//Reg_DT

                        if (DateTime.TryParse(Row["Nyuk_DT"].ToString(), out dt_Date))
                        {
                            str_Date = dt_Date.ToString("yyyyMMdd");
                        }
                        else
                        {
                            str_Date = DateTime.Now.ToString("yyyyMMdd");
                        }
                        //BarCode
                        str_Binary = "N" + SetLenth(Row["FB_NO"].ToString(), 20) +
                             SetLenth(Row["FBPOS_NO"].ToString(), 5) +
                             SetLenth(Row["SEQ_NO"].ToString(), 5) +
                             SetLenth(Row["Tori_CD"].ToString(), 15) +
                             SetLenth(Row["Shoh_CD"].ToString(), 80) +
                             SetLenth(Row["Lot_CD"].ToString(), 50) +
                             SetLenth("10", 2) +
                             SetLenth(Row["ALL_QT"].ToString(), 5) +
                             SetLenth(str_Date, 8);

                        str_ImageFile = Application.StartupPath + @"\Temp.Jpeg";
                        bc.Save(str_Binary, str_ImageFile, 100, 100);

                        range = xlReport.GetRange(Index + 5, "H", Index + 9, "H");
         
                        xlReport.InsertPictureBmp(Index + 5, "H", Index + 9, "H", str_ImageFile);//QRCode

                        ArrarIndex += 5;
                        i++;
                    }

                    //每页赋值

                    range = xlReport.GetRange(RowIndex + 5, "B", RowIndex + PageTotalRowCount, "G");
                    range.Value2 = dataArrayPage;

                    //设置边框
                    if (pageChild != 0)
                    {
                        range = xlReport.GetRange(RowIndex + 2, "A", RowIndex + PageTotalRowCount, "I");
                        range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeTop].LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlDouble;
                        range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeBottom].LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlDouble;
                        range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeLeft].LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlDouble;
                        range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeRight].LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlDouble;
                    }
 
                    //最后一列加宽。
                    range = xlReport.GetRange(RowIndex + PageTotalRowCount, "A");
                    double rowHeight = Convert.ToDouble(range.RowHeight.ToString());
                    rowHeight += 2d;
                    range.RowHeight = rowHeight;
                    xlReport.InsertVPageBreaks(RowIndex + PageTotalRowCount + 1);
                }

                xlReport.Print();
                xlReport.Close();
                //string str_Title = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Please_Set_Dest);
                //string str_InitialDir = @G_CommonClassSystem.G_System_GetDeskTopPath().ToString();
                //SaveFileDialog saveFileDialog = new SaveFileDialog();
                //saveFileDialog.Filter = "(*.xls)|*.xls|(*.*)|*.*";
                //saveFileDialog.FileName = "Receiving Inspection by PC A4 Label" + DateTime.Now.ToString("yyyyMMddHHmmss");
                //saveFileDialog.InitialDirectory = str_InitialDir;
                //if (saveFileDialog.ShowDialog() == DialogResult.OK)
                //{
                //    xlReport.SaveAs(saveFileDialog.FileName, true);
                //}
                //xlReport.Close();
                ////xlReport.PrintPreview();
            }
            catch (Exception err)
            {

                MessageBox.Show(err.Message);
            }
        }

        public static int G_F_Nyk_Inspection_HK_DataUpdate_POBAL_A4Label()
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            //SqlTransaction tran = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Disconnection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[6];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_GP);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_WorkCD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Nyk_Inspection_HK_DataUpdate_01_A4Label", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                return result;

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Connection();
                    }
                }
            }
        }

        public static int G_F_Nyk_Inspection_HK_DataUpdate_TL_A4Label()
        {
            int result = -1;
            SqlConnection sqlConnection = null;
            //SqlTransaction tran = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Disconnection();
                    return result;
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[6];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Tori_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_CD);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Section_Code", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_SEC_CD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Group_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_str_Customer_GP);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_WorkCD);
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Nyk_Inspection_HK_DataUpdate_TL_A4Label", sqlPara, out sqloutPara);

                result = Convert.ToInt32(sqloutPara[0].Value.ToString());

                return result;

            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Connection();
                    }
                }
            }
        }

        #endregion

        #endregion

        #region"Receiving Schedule"

        public static DataTable G_F_Nyk_EntryNykPlan_GetData_HD(string str_FB_NO)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[1];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Nyk_EntryNykPlan_SUB_DataSelect_HD", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count>0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #endregion

        #region "Packing Detail for HOEI Excel Report"
        public static void G_F_Syk_EntrySykPackDetail_HK_SUB_PackingReport()
        {
            string str_Message = string.Empty;
            string str_Caption = string.Empty;

            try
            {
                ExcelAccess xlReport = new ExcelAccess();
                string strPath = Application.StartupPath + @"\Report";
                string strExcelTemplateFile = System.IO.Path.GetFullPath(strPath + @"\Packing Detail for HOEI.xlt");
                string str_InitialDir = @G_CommonClassSystem.G_System_GetDeskTopPath().ToString();

                if (!System.IO.File.Exists(strExcelTemplateFile))
                {
                    str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Excel_Template_NoExists);
                    str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                    MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    xlReport.Close();
                    return;
                }

                DataTable dt = G_F_Syk_EntrySykPackDetail_HK_SUB_DataSelect_Report();
                if ((dt == null) || (dt.Rows.Count == 0))
                {
                    str_Message = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_DataNotExist);
                    str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Information);
                    MessageBox.Show(str_Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    xlReport.Close();
                    return;
                }

                xlReport.Open(strExcelTemplateFile);


                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["MIN_CASE"].ToString() == dt.Rows[i]["MAX_CASE"].ToString())
                        xlReport.SetCellText(i + 2, "A", dt.Rows[i]["MIN_CASE"].ToString());
                    else
                        xlReport.SetCellText(i + 2, "A", dt.Rows[i]["MIN_CASE"].ToString() + "-" + dt.Rows[i]["MAX_CASE"].ToString());
                    xlReport.SetCellText(i + 2, "B", dt.Rows[i]["CNTS"].ToString());
                    xlReport.SetCellText(i + 2, "C", dt.Rows[i]["GW"].ToString());
                    xlReport.SetCellText(i + 2, "D", Convert.ToInt16(dt.Rows[i]["L"]).ToString() + " * " +
                        Convert.ToInt16(dt.Rows[i]["W"]).ToString() + " * " +
                        Convert.ToInt16(dt.Rows[i]["H"]).ToString());
                    xlReport.SetCellText(i + 2, "E", dt.Rows[i]["Shoh_CM"].ToString());
                    xlReport.SetCellText(i + 2, "F", dt.Rows[i]["Shoh_CD"].ToString());
                    xlReport.SetCellText(i + 2, "G", dt.Rows[i]["SHOH_NM"].ToString());
                    xlReport.SetCellText(i + 2, "H", dt.Rows[i]["Yote_QT"].ToString());
                }

                
                //xlReport.PrintPreview();
                //保存Excel
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "(*.xls)|*.xls|(*.*)|*.*";
                saveFileDialog.FileName = "Packing Detail" + DateTime.Now.ToString("yyyyMMddHHmmss");
                saveFileDialog.InitialDirectory = str_InitialDir;
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    xlReport.SaveAs(saveFileDialog.FileName, true);
                }
                xlReport.ShowExcel();
                //xlReport.Application.ActivePrinter = @"\\PC01\PTE01 在 Ne04:";
                //xlReport.PrintPreview();
                //xlReport.Close();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        public static DataTable G_F_Syk_EntrySykPackDetail_HK_SUB_DataSelect_Report()
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }
                DataSet ds;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_Syk_EntrySykPackDetail_HK_PackingReport_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception ex)
            {
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(ex.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                {
                    P_MessageBox_Disconnection();
                }
            }
            return dt;
        }

        #endregion

        #region"A4 Serial Print"

        #region"Serial List"

        public static DataTable G_A4SerialPrint_GetHeaderData(string str_FB_NO, string str_FBPOS_NO, string str_SEQ)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[3];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FBPOS_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FBPOS_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SEQ_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_SEQ);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_HHT_ReportSerial_DataSearch_Serial", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static DataTable G_A4SerialPrint_GetDetailData(string str_FB_NO, string str_FBPOS_NO, string str_SEQ)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[3];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FBPOS_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FBPOS_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SEQ_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_SEQ);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_COM_T_Serial_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        public static DataTable G_A4SerialPrint_SearchData(string str_PrintQue_No)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[1];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PrintQue_No", ParameterDirection.Input, SqlDbType.Int, 0, str_PrintQue_No);


                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_R_HOEI_Carton_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #endregion

        #region "Lot Label Print"

        public static DataTable G_LotLabelList_GetData(string str_FB_NO, string str_FBPOS_NO, string str_SEQ)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[3];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FB_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FB_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FBPOS_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_FBPOS_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SEQ_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_SEQ);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_HHT_ReportPLotList_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
                return dt;
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
        }

        #endregion

        #region" LGE Label"

        #region "LGE Label Data Entry"

        public static int G_F_LGELabelDataEntry_Sub_Update(string str_Mode, string str_ID, string str_GP_NO, string str_GPPOS_NO, string str_LGEP_NO, string str_MakerP_NO, string str_Lot_NO, string str_SEQ_NO, string QTY, string str_PC_NM, ref string str_ErrMsg)
        {
            int result = -11;

            SqlConnection sqlConnection = null;
            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[11];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ID", ParameterDirection.Input, SqlDbType.Int, 0, str_ID);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@GP_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_GP_NO);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@GPPOS_NO", ParameterDirection.Input, SqlDbType.Int, 0, str_GPPOS_NO);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@LGEP_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_LGEP_NO);

                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@MakerP_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_MakerP_NO);
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Lot_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Lot_NO);
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@SEQ_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_SEQ_NO);
                sqlPara[8] = G_CommonClassDB.G_DB_SetSQLDBParameter("@QTY", ParameterDirection.Input, SqlDbType.Int, 0, QTY);
                sqlPara[9] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);

                sqlPara[10] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");
             //   sqlPara[11] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ErrMsg", ParameterDirection.Output, SqlDbType.VarChar, 0, "");
                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_LGELabelDataEntry_SUB_DataUpdate", sqlPara, out sqloutPara);

                result = int.Parse(sqloutPara[0].Value.ToString());
                //str_ErrMsg = sqloutPara[1].Value.ToString();
            }
            catch (Exception err)
            {


                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "USP_PC_F_LGELabelDataEntry_SUB_DataUpdate" + err.Message, "USP_PC_F_LGELabelDataEntry_SUB_DataUpdate");
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }


            return result;
        }

        public static DataTable G_F_LGELabelDataEntry_GetData_Sub(string str_PC_NM)
        {
            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_LGELabelDataEntry_SUB_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_LGELabelDataEntry_GetData_Sub" + err.Message, "G_F_LGELabelDataEntry_GetData_Sub");
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        public static int G_F_LGELabelDataEntry_WorkerDataDelete(string str_PC_NM)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[2];
  
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);

                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");


                SqlParameter[] sqlOutPara;

                //ストアド実行
                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_LGELabelDataEntry_WorkDataDelete", sqlPara, out sqlOutPara);

                result = int.Parse(sqlOutPara[0].Value.ToString());
            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_LGELabelDataEntry_WorkerDataDelete" + err.Message, "G_F_LGELabelDataEntry_WorkerDataDelete");
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return result;
        }

        public static int G_F_LGELabelDataEntry_DataUpdate(string str_Mode, string str_GP_NO, ref string str_ErrMsg)
        {
            int result = -11;

            SqlConnection sqlConnection = null;
            try
            {

                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[6];

                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@GP_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_GP_NO);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_WorkCD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_PCNM);
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret",ParameterDirection.InputOutput,SqlDbType.Int,0,"0");
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ErrMsg", ParameterDirection.InputOutput, SqlDbType.VarChar, 0, "");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_LGELabelDataEntry_DataUpdate", sqlPara, out sqloutPara);

                result = int.Parse(sqloutPara[0].Value.ToString());
                str_ErrMsg = sqloutPara[1].Value.ToString();

            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_LGELabelDataEntry_DataUpdate" + err.Message, "G_F_LGELabelDataEntry_DataUpdate");
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        public static DataTable G_F_COM_Search_GroupID_GetData(string str_Search_Mode, string str_Search_CD)
        {
            DataTable dt = null;
            SqlConnection sqlConnection = null;

            try
            {

                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[2];


                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_Mode", ParameterDirection.Input, SqlDbType.Int, 0, str_Search_Mode);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Search_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, str_Search_CD);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_COM_Search_GroupID_DataSelect", sqlPara, out ds);
                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }
            }
            catch (Exception err)
            {

                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_COM_Search_GroupID_GetData" + err.Message, "G_F_COM_Search_GroupID_GetData");
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return dt;
        }

        public static DataTable G_F_LGELabelDataEntry_GetData(string str_GP_NO)
        {

            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@GP_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_GP_NO);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_F_LGELabelDataEntry_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_LGELabelDataEntry_GetData" + err.Message, "G_F_LGELabelDataEntry_GetData");
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        public static int G_F_LGELabelDataEntry_Insert(string str_GP_NO, string str_PC_NM)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[3];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@GP_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_GP_NO);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.Output, SqlDbType.Int, 0, "0");

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_F_LGELabelDataEntry_DataInsert", sqlPara, out sqloutPara);

                result = int.Parse(sqloutPara[0].Value.ToString());
            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_LGELabelDataEntry_Insert" + err.Message, "G_F_LGELabelDataEntry_Insert");
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }


        public static DataTable G_F_LGELabelDataEntry_Print_GetData(string str_GP_NO)
        {

            DataTable dt = null;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                    return dt;
                }

                DataSet ds = null;
                SqlCommand sqlCommand = sqlConnection.CreateCommand();

                SqlParameter[] sqlPara = new SqlParameter[1];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@GP_NO", ParameterDirection.Input, SqlDbType.VarChar, 0, str_GP_NO);

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_F_LGELabelDataEntry_Print_DataSelect", sqlPara, out ds);

                if ((ds != null) && (ds.Tables.Count > 0))
                {
                    dt = ds.Tables[0];
                }

            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_LGELabelDataEntry_Print_GetData" + err.Message, "G_F_LGELabelDataEntry_Print_GetData");
                dt = null;
                return dt;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }

            return dt;
        }

        public static ds_LGELabel G_PrintLGELabel(DataTable dtLabel)
        {
            ds_LGELabel ds_LGE = new ds_LGELabel();

            DataMatrix.net.DmtxImageEncoder encoder = new DataMatrix.net.DmtxImageEncoder();
            DataMatrix.net.DmtxImageEncoderOptions options = new DataMatrix.net.DmtxImageEncoderOptions();
            options.ModuleSize = 8;
            options.MarginSize = 4;
            options.BackColor = Color.White;
            options.ForeColor = Color.Green;

            BarcodeLibLine.Barcode LineBarCode = new BarcodeLibLine.Barcode();
            LineBarCode.EncodedType = BarcodeLibLine.TYPE.CODE128;

            string filename = Application.StartupPath + @"\Temp_LGELabel.png";

            try
            {
                foreach (DataRow Row in dtLabel.Rows)
                {
                    DataRow dr_LGELable = ds_LGE.Tables[0].NewRow();

                    dr_LGELable["GP_NO"] = Row["GP_NO"];
                    dr_LGELable["GPPOS_NO"] = Row["GPPOS_NO"];
                    dr_LGELable["LGEP_NO"] = Row["LGEP_NO"];
                    dr_LGELable["MakerP_NO"] = Row["MakerP_NO"];
                    dr_LGELable["Lot_NO"] = Row["Lot_NO"];
                    dr_LGELable["SEQ_NO"] = Row["SEQ_NO"];
                    dr_LGELable["QTY"] = Row["QTY"];


                    //LGE P/NO Barcode
                    LineBarCode.RawData = Row["LGEP_NO"].ToString().Trim();
                    LineBarCode.Encode();
                    LineBarCode.SaveImage(filename,BarcodeLibLine.SaveTypes.PNG);
                    dr_LGELable["LGEP_NO_BarCode"] = File.ReadAllBytes(filename);

                    //Maker P/NO Barcode
                    LineBarCode.RawData = Row["MakerP_NO"].ToString().Trim();
                    LineBarCode.Encode();
                    LineBarCode.SaveImage(filename,BarcodeLibLine.SaveTypes.PNG);
                    dr_LGELable["MakerP_NO_BarCode"] = File.ReadAllBytes(filename);

                    //LOT NO Barcode
                    LineBarCode.RawData = Row["Lot_NO"].ToString().Trim();
                    LineBarCode.Encode();
                    LineBarCode.SaveImage(filename,BarcodeLibLine.SaveTypes.PNG);
                    dr_LGELable["Lot_NO_BarCode"] = File.ReadAllBytes(filename);

                    //QTY Barcode
                    LineBarCode.RawData = Row["QTY"].ToString().Trim();
                    LineBarCode.Encode();
                    LineBarCode.SaveImage(filename,BarcodeLibLine.SaveTypes.PNG);
                    dr_LGELable["QTY_BarCode"] = File.ReadAllBytes(filename);

                    //2D DataMatrix
                    //LGE P/NO + ! + SQE_NO + ! Maker P/NO + ! + LOT NO + ! + QTY

                    string str_DataMatrix = Row["LGEP_NO"].ToString().Trim() + "!" + Row["SEQ_NO"].ToString().Trim() + "!" + Row["MakerP_NO"].ToString().Trim() + "!" + Row["Lot_NO"].ToString().Trim() + "!" + Row["QTY"].ToString().Trim();
                   //  DataMatrixBarCode.Data = str_DataMatrix;
                   ////  DataMatrixBarCode.drawBarcode(filename);
                    //dr_LGELable["DataMatrix"] = DataMatrixBarCode.drawBarcodeAsBytes();
                    Bitmap encodedBitmap = encoder.EncodeImage(str_DataMatrix);
                    encodedBitmap.Save(filename, ImageFormat.Png);
                    dr_LGELable["DataMatrix"] = File.ReadAllBytes(filename);
                    ds_LGE.Tables[0].Rows.Add(dr_LGELable);
                }
                ds_LGE.AcceptChanges();
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
            return ds_LGE;
        }

        #endregion


        #region "LGE LABEL Data Import"


        public static int G_F_LGELabelDataImport_DataImport(string fileName, string str_PC_NM, ref string ErrMsg,ref int In_Cnt,ref int Out_Cnt,ref int Err_Cnt)
        {
            int result = -11;

            SqlConnection sqlConnection = null;

            try
            {
                if (!G_CommonClassDB.G_DB_Connect(out sqlConnection))
                {
                    P_MessageBox_Connection();
                }
                SqlCommand sqlCommand = sqlConnection.CreateCommand();
                SqlParameter[] sqlPara = new SqlParameter[8];
                sqlPara[0] = G_CommonClassDB.G_DB_SetSQLDBParameter("@FilePath", ParameterDirection.Input, SqlDbType.VarChar, 0, fileName);
                sqlPara[1] = G_CommonClassDB.G_DB_SetSQLDBParameter("@PC_NM", ParameterDirection.Input, SqlDbType.VarChar, 0, str_PC_NM);
                sqlPara[2] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Work_CD", ParameterDirection.Input, SqlDbType.VarChar, 0, G_CommonDefine.G_WorkCD);
                sqlPara[3] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Ret", ParameterDirection.InputOutput, SqlDbType.Int, 0, "0");
                sqlPara[4] = G_CommonClassDB.G_DB_SetSQLDBParameter("@ErrMsg", ParameterDirection.InputOutput, SqlDbType.VarChar, 500, "");
                sqlPara[5] = G_CommonClassDB.G_DB_SetSQLDBParameter("@In_Cnt", ParameterDirection.InputOutput, SqlDbType.Int, 0, "0");
                sqlPara[6] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Out_Cnt", ParameterDirection.InputOutput, SqlDbType.Int, 0, "0");
                sqlPara[7] = G_CommonClassDB.G_DB_SetSQLDBParameter("@Err_Cnt", ParameterDirection.InputOutput, SqlDbType.Int, 0, "0");
               

                SqlParameter[] sqloutPara;

                G_CommonClassDB.G_DB_ExecStoredProc(sqlConnection, sqlCommand, "USP_PC_F_LGELabel_DataInsert", sqlPara, out sqloutPara);

                result = int.Parse(sqloutPara[0].Value.ToString());
                ErrMsg = sqloutPara[1].Value.ToString();
                In_Cnt = int.Parse(sqloutPara[2].Value.ToString());
                Out_Cnt = int.Parse(sqloutPara[3].Value.ToString());
                Err_Cnt = int.Parse(sqloutPara[4].Value.ToString());

            }
            catch (Exception err)
            {

                G_CommonClassSystem.G_System_SetLog(G_CommonDefine.LogMode.Error, "G_F_LGELabelDataEntry_Insert" + err.Message, "G_F_LGELabelDataEntry_Insert");
                string str_Caption = G_CommonClassSystem.G_System_GetMessage(G_CommonDefine.G_Message_Error);
                MessageBox.Show(err.Message, str_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return result;
            }
            finally
            {
                if (sqlConnection != null)
                {
                    if (!G_CommonClassDB.G_DB_Dispose(sqlConnection))
                    {
                        P_MessageBox_Disconnection();
                    }
                }
            }
            return result;
        }

        #endregion

        #endregion

    }
}
